1. Juan Carlos Picado Herrera
  2. encuestame

Commits

Juan Carlos Picado Herrera  committed 3e37a9b

Migrated NotificationList widget

  • Participants
  • Parent commits 389e6ee
  • Branches master

Comments (0)

Files changed (10)

File enme-war/src/main/webapp/WEB-INF/views/notifications/tiles.xml

View file
         <put-attribute name="extra-js" expression="/WEB-INF/views/notifications/${detectedDevice ? 'mobile/' : 'web/'}js.jsp" />
     </definition>
 
-    <definition name="user/notification/id" extends="page">
+<!--     <definition name="user/notification/id" extends="page">
         <put-attribute name="title" value="Notification Detail | encuestame" />
         <put-attribute name="menu" expression="/WEB-INF/jsp/includes/${detectedDevice ? 'mobile/' : 'web/'}menu.jsp" />
         <put-attribute name="content" expression="/WEB-INF/views/notifications/${detectedDevice ? 'mobile/' : 'web/'}notification.jsp" />
         <put-attribute name="extra-js" expression="/WEB-INF/views/notifications/${detectedDevice ? 'mobile/' : 'web/'}js.jsp" />
     </definition>
-
+ -->
 
 </tiles-definitions>

File enme-war/src/main/webapp/WEB-INF/views/notifications/web/notification.jsp

View file
+<!-- remove this file -->

File enme-war/src/main/webapp/WEB-INF/views/notifications/web/notifications.jsp

View file
 <%@ include file="/WEB-INF/jsp/includes/taglibs.jsp"%>
 <div class="defaultMarginWrapper">
-    <div dojoType="encuestame.org.core.commons.notifications.NotificationList"></div>
+    <div data-dojo-type="me/web/widget/notifications/NotificationList"></div>
 </div>

File enme-war/src/main/webapp/resource/css-compile/development.css

View file
 @import url("web/table.css");
 @import url("web/user.css");
 @import url("web/components/front-aside.css");
+@import url("web/components/notification-list.css");
 @import url("web/components/front.css");
 @import url("web/components/profile.css");
 @import url("web/components/front-end-items.css");

File enme-war/src/main/webapp/resource/css-compile/web/components/notification-list.css

View file
+/** notifilication list **/
+div.web-notification-list {
+
+}
+
+div.web-notification-list list {
+
+}
+
+div.web-notification-list div.web-notification-list-item {
+    clear: both;
+    padding: 9px;
+    font-size: 100%;
+    text-align: left;
+    border-bottom: 1px solid #E9E9E9;
+}
+
+div.web-notification-list div.web-notification-list-item span {
+    margin-left: 5px;
+    margin-right: 10px;
+    font-size: 100%;
+}
+
+div.web-notification-list div.web-notification-list-item .icon {
+    width: 16px;
+    background-repeat: no-repeat;
+    display: inline-block;
+}
+
+div.web-notification-list div.web-notification-list-item .title {
+    font-weight: bold;
+    padding: 4px;
+    min-width: 265px;
+    max-width: 265px;
+    display: inline-block;
+}
+
+div.web-notification-list div.web-notification-list-item .description {
+    padding: 4px;
+    min-width: 405px;
+    display: inline-block;
+    max-width: 405px;
+}
+
+div.web-notification-list div.web-notification-list-item .date {
+    padding-left: 10px;
+    color: gray;
+    padding: 4px;
+    display: inline-block;
+}

File enme-war/src/main/webapp/resource/css-compile/web/public.css

View file
     padding: 5px;
 }
 
-/** notifilication list **/
-div.web-notification-list {
-
-}
-
-div.web-notification-list list {
-
-}
-
-div.web-notification-list div.web-notification-list-item {
-    clear: both;
-    padding: 9px;
-    font-size: 100%;
-    text-align: left;
-    border-bottom: 1px solid #E9E9E9;
-}
-
-div.web-notification-list div.web-notification-list-item span {
-    margin-left: 5px;
-    margin-right: 10px;
-    font-size: 100%;
-}
-
-div.web-notification-list div.web-notification-list-item .icon {
-    width: 16px;
-    background-repeat: no-repeat;
-    display: inline-block;
-}
-
-div.web-notification-list div.web-notification-list-item .title {
-    font-weight: bold;
-    padding: 4px;
-    min-width: 265px;
-    max-width: 265px;
-    display: inline-block;
-}
-
-div.web-notification-list div.web-notification-list-item .description {
-    padding: 4px;
-    min-width: 405px;
-    display: inline-block;
-    max-width: 405px;
-}
-
-div.web-notification-list div.web-notification-list-item .date {
-    padding-left: 10px;
-    color: gray;
-    padding: 4px;
-    display: inline-block;
-}
 
 /** Poll Page Detail **/
 .web-poll-detail-wrapper {
 }
 
 
-
 .stats-button {
     cursor: pointer;
     min-height: 80px;

File enme-war/src/main/webapp/resource/js/me/web/widget/notifications/Notification.js

View file
           */
          limit: _ENME.config('activity').limit,
 
+        /**
+         *
+         * @property
+         */
          i18nMessage : {
-           not_view_all : _ENME.getMessage("not_view_all"),
+           not_view_all : _ENME.getMessage("not_view_all")
          },
 
          /*
          _viewAll : function(event){
               dojo.stopEvent(event);
               //dijit.byId("allNot").show();
-              document.location.href = encuestame.contextDefault+"/user/notifications";
+              document.location.href = _ENME.config('contextPath') + "/user/notifications";
          },
 
          /*

File enme-war/src/main/webapp/resource/js/me/web/widget/notifications/NotificationList.js

View file
-dojo.provide("encuestame.org.core.commons.notifications.NotificationList");
-
-dojo.require('dojox.timing');
-dojo.require("dojox.widget.Dialog");
-dojo.require("dijit._Templated");
-dojo.require("dijit._Widget");
-dojo.require("dijit.layout.ContentPane");
-dojo.require('encuestame.org.core.commons');
+/*
+ * Copyright 2013 encuestame
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 
-dojo.declare(
-    "encuestame.org.core.commons.notifications.NotificationList",
-    [dijit._Widget, dijit._Templated],{
-        templatePath: dojo.moduleUrl("encuestame.org.core.commons.notifications", "template/notificationList.html"),
+/***
+ *  @author juanpicado19D0Tgm@ilDOTcom
+ *  @version 1.146
+ *  @module Notifications
+ *  @namespace Widget
+ *  @class NotificationList
+ */
 
-        widgetsInTemplate: true,
+define([
+         "dojo",
+         'dojo/_base/json',
+         "dojo/_base/declare",
+         "dijit/_WidgetBase",
+         "dijit/_TemplatedMixin",
+         "dijit/_WidgetsInTemplateMixin",
+         "me/core/main_widgets/EnmeMainLayoutWidget",
+         "me/web/widget/notifications/NotificationListItem",
+         "me/core/enme",
+         "dojo/text!me/web/widget/notifications/template/notificationList.html" ],
+        function(
+                dojo,
+                json,
+                declare,
+                _WidgetBase,
+                _TemplatedMixin,
+                _WidgetsInTemplateMixin,
+                main_widget,
+                NotificationListItem,
+                _ENME,
+                 template) {
+            return declare([ _WidgetBase, _TemplatedMixin, main_widget, _WidgetsInTemplateMixin], {
+
+        /**
+         * template string.
+         * @property templateString
+         */
+        templateString : template,
 
+        /**
+         *
+         * @property arrayNotifications
+         */
         arrayNotifications : null,
 
+        /**
+         *
+         * @property mobile
+         */
         mobile : false,
 
+        /**
+         *
+         * @property _start
+         */
         _start : 0,
 
-        _limit :  encuestame.notification.load.limit,
+        /**
+         *
+         * @property _limit
+         */
+        _limit :  _ENME.config('activity').limit,
 
+        /**
+         *
+         * @property
+         */
         _seeMoreValue : false,
 
-        postCreate : function(){
+        /**
+         * postCreate life cycle
+         * @method postCreate
+         */
+        postCreate : function() {
             this._loadNotifications(this._start);
         },
 
-        /*
-         * load notifications.
+        /**
+         * Load notifications.
+         * @method _loadNotifications
          */
-        _loadNotifications : function(start){
+        _loadNotifications : function(start) {
             var load = dojo.hitch(this, function(data) {
                  this.arrayNotifications = data.success.notifications;
                  this._showListCategories();
              if (start == null) {
                  start = 0;
              }
-             var params = {limit : this._limit, start: start, categorized: true};
-             encuestame.service.xhrGet(
-                     encuestame.service.list.getAllNotifications, params, load, error);
+             var params = {
+                    limit : this._limit,
+                    start: start,
+                    categorized: true
+                };
+             this.getURLService().get("encuestame.service.list.getAllNotifications", params, load, error , dojo.hitch(this, function() { }));
         },
 
         /*
          *
+         * @method _loadMoreNotifications
          */
         _loadMoreNotifications : function(event){
-                console.debug("MORE ENCUESTAME-234", event);
+                //console.debug("MORE ENCUESTAME-234", event);
         },
 
-        /*
+        /**
          * see more items.
+         * @method _seeMore
          */
         _seeMore : function(){
             //only for mobile interface. override.
-        } ,
+        },
 
-        /*
+        /**
          * build notification category section.
+         * @method _buildSection
          */
-        _buildSection : function(name, content){
+        _buildSection : function(name, content) {
              var section = dojo.doc.createElement("div");
              dojo.addClass(section, "section");
 
              //add content
              section.appendChild(content);
              //add see more
-             if(this._seeMoreValue){
+             if( this._seeMoreValue) {
                  section.appendChild(this._seeMore());
              }
              this._list.appendChild(section);
         },
 
-        _createNotificationItem : function(item, category){
-             var widget = new encuestame.org.core.commons.notifications.NotificationListItem({
+        /**
+         * Create a notification list item
+         * @method _createNotificationItem
+         */
+        _createNotificationItem : function(item, category) {
+             var widget = new NotificationListItem({
                  item : item,
                  category : "TODAY"});
             return widget;
          * show list categories.
          */
         _showListCategories : function() {
-            console.debug("_showListCategories");
             var today = this.arrayNotifications.TODAY;
             var items = dojo.doc.createElement("div");
             if (today.length > 0) {
             console.debug("lastYear", lastYear);
             console.debug("longTimeAgo", longTimeAgo);
         }
-});
-
-/**
- *
- */
-dojo.declare(
-        "encuestame.org.core.commons.notifications.NotificationListItem",
-        [dijit._Widget, dijit._Templated],{
-            templatePath: dojo.moduleUrl("encuestame.org.core.commons.notifications", "template/notificationListItem.html"),
-
-            widgetsInTemplate: true,
-
-            item : null,
-
-            category : null,
-
-            postCreate : function() {
-                console.debug("item", this.item);
-                if (this.item.url != null) {
-                    this._description
-                    .appendChild(encuestame.notification
-                    .buildURLDescription(
-                            this.item.type,
-                            this.item.additionalDescription,
-                            this.item.url));
-                } else {
-                    this._description.innerHTML = this.item.additionalDescription;
-                }
-            },
-
-            /*
-             * remove.
-             */
-            _remove : function(event){
-                //TODO: display dialog.
-                this._removeNotification();
-            },
-
-            /*
-             * remove notification
-             */
-            _removeNotification : function(){
-                var load = dojo.hitch(this, function(data) {
-                     dojo.destroy(this.domNode);
-                 });
-                 var error = function(error) {
-                     console.debug("error", error);
-                 };
-                 var params = {notificationId : this.item.id};
-                 encuestame.service.xhrGet(
-                         encuestame.service.list.removeNotification, params, load, error);
-            }
 
+    });
 });

File enme-war/src/main/webapp/resource/js/me/web/widget/notifications/NotificationListItem.js

View file
+/*
+ * Copyright 2013 encuestame
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/***
+ *  @author juanpicado19D0Tgm@ilDOTcom
+ *  @version 1.146
+ *  @module Notifications
+ *  @namespace Widget
+ *  @class NotificationListItem
+ */
+
+define([
+         "dojo",
+         'dojo/_base/json',
+         "dojo/_base/declare",
+         "dijit/_WidgetBase",
+         "dijit/_TemplatedMixin",
+         "dijit/_WidgetsInTemplateMixin",
+         "me/core/main_widgets/EnmeMainLayoutWidget",
+         "me/web/widget/notifications/NotificationListItem",
+         "me/core/enme",
+         "dojo/text!me/web/widget/notifications/template/notificationListItem.html" ],
+        function(
+                dojo,
+                json,
+                declare,
+                _WidgetBase,
+                _TemplatedMixin,
+                _WidgetsInTemplateMixin,
+                main_widget,
+                NotificationListItem,
+                _ENME,
+                 template) {
+            return declare([ _WidgetBase, _TemplatedMixin, main_widget, _WidgetsInTemplateMixin], {
+
+        /**
+         * template string.
+         * @property templateString
+         */
+        templateString : template,
+
+        /**
+         *
+         * @property
+         */
+        item : null,
+
+        /**
+         *
+         * @property
+         */
+        category : null,
+
+        /**
+         *
+         * @method
+         */
+        postCreate : function() {
+            if (this.item.url != null) {
+                this._description
+                .appendChild(encuestame.notification
+                .buildURLDescription(
+                        this.item.type,
+                        this.item.additionalDescription,
+                        this.item.url));
+            } else {
+                this._description.innerHTML = this.item.additionalDescription;
+            }
+        },
+
+        /**
+         * remove notification.
+         * @method _removeNotification
+         */
+        _remove : function(event) {
+            //TODO: display dialog.
+            this._removeNotification();
+        },
+
+        /**
+         * remove notification.
+         * @method _removeNotification
+         */
+        _removeNotification : function() {
+            var load = dojo.hitch(this, function(data) {
+                 dojo.destroy(this.domNode);
+             });
+             var error = function(error) {
+                 console.debug("error", error);
+             };
+             var params = {
+                    notificationId : this.item.id
+                };
+             this.getURLService().get("encuestame.service.list.removeNotification", params, load, error , dojo.hitch(this, function() { }));
+        }
+
+    });
+});

File enme-war/src/main/webapp/resource/js/me/web/widget/notifications/template/notificationListItem.html

View file
 <div class="web-notification-list-item">
     <span class="icon">
-        <img alt="icon" dojoAttachPoint="_list">
+        <img alt="icon" data-dojo-attach-point="_list">
     </span>
     <span class="title">
         ${item.description}
     </span>
-    <span class="description" dojoAttachPoint="_description">
+    <span class="description" data-dojo-attach-point="_description">
     </span>
     <span class="date">
           ${item.date} | ${item.hour}
     </span>
      <span class="options">
         <span class="">
-            <a href="#" dojoAttachEvent="onclick:_remove">Delete</a>
+            <a href="#" data-dojo-attach-event="onclick:_remove">
+                Delete
+            </a>
         </span>
      </span>
 </div>