widgets.pbDataTable.assets.js.bonita-lib-tpl-0.5.21.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ui-designer-artifact-builder-generator-angularjs Show documentation
Show all versions of ui-designer-artifact-builder-generator-angularjs Show documentation
This module is a generator on AngularJS for Artifact Builder
"use strict";angular.module("org.bonitasoft.bonitable",[]).controller("BonitableController",["$scope",function(t){function e(t){return t.isChecked()}function n(t){return t.data}this.getOptions=function(){return t.sortOptions},this.setOptions=function(e){t.sortOptions=e},this.onStorageLoaded=function(){return t.onStorageLoaded()},this.triggerSortHandler=function(e){t.onSort({options:e})};var o=[];this.registerSelector=function(t){o.push(t)},this.unregisterSelector=function(t){o.splice(o.indexOf(t),1)};var r={$selectedItems:function(){return o.filter(e).map(n)},$allSelected:function(){return this.$selectedItems.length===o.length},$indeterminate:function(){return this.$selectedItems.length!==o.length&&this.$selectedItems.length>0}};this.prepareScope=function(t){Object.keys(r).forEach(function(t){Object.defineProperty(this,t,{get:r[t],enumerable:!0,iterable:!0})},t),t.$toggleAll=function(){var t=!this.$allSelected;o.forEach(function(e){e.setChecked(t)})}}}]).directive("bonitable",function(){return{priority:100,scope:{onSort:"&",sortOptions:"=",repeatableConfig:"=",onStorageLoaded:"&"},transclude:"element",controller:"BonitableController",compile:function(){return function(t,e,n,o,r){r(function(t,n){o.prepareScope(n),e.after(t)})}}}}),angular.module("org.bonitasoft.dragAndDrop",[]).provider("boDraggableItem",function(){var t={cloneOnDrop:!0,bodyClass:!1};this.cloneOnDrop=function(e){t.cloneOnDrop=e},this.activeBodyClassName=function(e){t.bodyClass=e},this.$get=function(){return{config:function(){return angular.copy(t)},allowCloneOnDrop:function(){return this.config().cloneOnDrop||!1},setBodyClass:function(){return!!this.config().bodyClass}}}}).service("boDragUtils",function(){this.generateUniqId=function(t){return(t||"drag-")+Math.random().toString(36).substring(7)},this.polyfillIE=function(t){Array.prototype.forEach.call(t,function(t){angular.element(t).on("selectstart",function(){return this.dragDrop(),!1})})},this.getDragInitiatorNode=function(t){for(var e=t;e.parentNode;){if("true"===e.getAttribute("draggable"))return e;e=e.parentNode}return null}}).directive("boDropzone",["$document","$parse","$compile","boDragUtils","boDragEvent","boDraggableItem",function(t,e,n,o,r,a){var i={},l=r.events.DROPZONE_CLASSNAME_HOVER,s=r.events.DRAGITEM_OWN_DROPZONE,c=r.events.CLASSNAME_DRAG_HOVER;return t.on("dragenter",function(t){if(t.target.hasAttribute("data-drop-id")){var e=!!angular.element("#"+r.currentDragItemId).find("[draggable] [data-drop-id="+t.target.getAttribute("data-drop-id")+"]")[0],n=!!angular.element("#"+r.currentDragItemId).find("[data-drop-id="+t.target.getAttribute("data-drop-id")+"]")[0];angular.element(document.querySelectorAll("."+s)).removeClass(s),(e||n)&&(t.target.className+=" "+s),angular.element(document.querySelectorAll("."+l)).removeClass(l),t.target.className+=" "+l}}),t.on("dragover",function(t){if(t.preventDefault(),t.target.hasAttribute("data-drop-id")){var e=t.target.getAttribute("data-drop-id");return i[e].onDragOver(i[e].scope,{$event:t}),(t.dataTransfer||t.originalEvent.dataTransfer).dropEffect="copy",!1}}),t.on("drop",function(t){if(t.preventDefault(),a.setBodyClass()&&angular.element(document.body).removeClass("bo-drag-action"),t.target.hasAttribute("data-drop-id")){var e=t.target.getAttribute("data-drop-id"),s=JSON.parse((t.dataTransfer||t.originalEvent.dataTransfer).getData("Text")),u=document.getElementById(s.dragItemId),d=i[e].scope,p=r.map[s.dragItemId],g=p.data;if(s.isDropZoneChild)t.target.appendChild(u);else{var b=u.cloneNode(!0);b.id=o.generateUniqId(),r.copy(s.dragItemId,b.id);try{b.attributes.removeNamedItem("ng-repeat")}catch(t){}a.allowCloneOnDrop()&&t.target.appendChild(b),n(angular.element(b))(r.map[b.id].scope)}d.$apply(function(){angular.element(document.getElementsByClassName(l)).removeClass(l),angular.element(document.getElementsByClassName(c)).removeClass(c),p.onDropItem(d,{$data:g,$event:t}),i[e].onDropSuccess(d,{$data:g,$event:t})})}}),{type:"A",link:function(t,n,r){n.addClass("bo-dropzone-container"),r.$set("data-drop-id",o.generateUniqId("drop")),i[r["data-drop-id"]]={scope:t,onDropSuccess:e(r.boDropSuccess),onDragOver:e(r.boDragOver)}}}}]).factory("boDragEvent",function(){var t={};return{map:t,events:{DROPZONE_CLASSNAME_HOVER:"bo-dropzone-hover",DRAGITEM_OWN_DROPZONE:"bo-drag-dropzone-child",CLASSNAME_DRAG_HOVER:"bo-drag-enter"},copy:function(e,n){t[n]=t[e]}}}).directive("boDraggable",["$document","$parse","boDragEvent","boDragUtils","boDraggableItem",function(t,e,n,o,r){return t.on("dragstart",function(t){var e=o.getDragInitiatorNode(t.target),a=t.dataTransfer||t.originalEvent.dataTransfer;r.setBodyClass()&&angular.element(document.body).addClass("bo-drag-action"),a.effectAllowed="copy",a.setData("Text",JSON.stringify({dragItemId:e.id,isDropZoneChild:e.parentElement.hasAttribute("data-drop-id")})),n.currentDragItemId=e.id,n.map[e.id]&&n.map[e.id].onDragStart(n.map[e.id].scope)}),t.on("dragenter",function(t){t.target.className.indexOf(n.events.CLASSNAME_DRAG_HOVER)>-1||(angular.element(document.getElementsByClassName(n.events.CLASSNAME_DRAG_HOVER)).removeClass(n.events.CLASSNAME_DRAG_HOVER),t.target.className+=" "+n.events.CLASSNAME_DRAG_HOVER)}),t.on("dragleave",function(t){t.target.className.indexOf(n.events.CLASSNAME_DRAG_HOVER)>-1&&(t.target.className=t.target.className.replace(" "+n.events.CLASSNAME_DRAG_HOVER,""))}),{link:function(t,r,a){a.$set("draggable",!0),a.$set("id",a.id||o.generateUniqId()),n.map[a.id]={key:a.boDraggableData,scope:t,onDragStart:e(a.boDragStart),onDropItem:e(a.boDropItem)},t.$evalAsync(function(t){n.map[a.id].data=t[a.boDraggableData]})}}}]).directive("boDragPolyfill",["$window","$document","$timeout","boDragUtils",function(t,e,n,o){return t.navigator.userAgent.indexOf("MSIE 9")>-1&&e.on("drop",function(t){t.preventDefault(),n(function(){o.polyfillIE(document.querySelectorAll("[bo-draggable], [data-bo-draggable]"))},100)}),{type:"EA",link:function(){t.navigator.userAgent.indexOf("MSIE 9")>-1&&n(function(){o.polyfillIE(document.querySelectorAll("[bo-draggable], [data-bo-draggable]"))},100)}}}]),function(){angular.module("org.bonitasoft.services.topurl",[]).service("manageTopUrl",["$window",function(t){var e={};return e.getCurrentPageToken=function(){var e=/(^|[&\?])_p=([^&]*)(&|$)/,n=e.exec(t.top.location.hash);return Array.isArray(n)?n[2]:""},e.addOrReplaceParam=function(n,o){if(void 0!==o&&t.self!==t.top){var r=e.getCurrentPageToken();if(t.top.location.hash){var a=new RegExp("(^|[&\\?])"+r+n+"=[^&]*(&|$)"),i=t.top.location.hash.match(a);if(Array.isArray(i)){var l="";o&&(l=r+n+"="+o),t.top.location.hash=t.top.location.hash.replace(a,"$1"+l+"$2")}else{var s=t.top.location.hash;o&&(t.top.location.hash+=(s.indexOf("&",s.length-2)>=0?"":"&")+r+n+"="+o)}return}o&&(t.top.location.hash="#"+r+n+"="+o)}},e.getCurrentProfile=function(){if(t&&t.top&&t.top.location&&t.top.location.hash){var e=t.top.location.hash.match(/\b_pf=\d+\b/);return Array.isArray(e)?e[0]:""}},e.getPath=function(){return t.top.location.pathname},e.getSearch=function(){return t.top.location.search||""},e.getUrlToTokenAndId=function(t,n){return e.getPath()+e.getSearch()+"#?id="+(t||"")+"&_p="+(n||"")+"&"+e.getCurrentProfile()},e.goTo=function(n){var o="&";if(angular.isUndefined(n))throw new TypeError("You must pass an Object as argument");if("string"==typeof n)return void(t.top.location.hash="?_p="+n+"&"+e.getCurrentProfile());var r=!angular.isDefined(n.prependToken)||!!n.prependToken;if(!n.token)throw new Error("You must set a token to define the destination page");angular.forEach(n,function(t,e){e&&t&&"token"!==e&&"prependToken"!==e&&(o+=(r?n.token:"")+e+"="+t+"&")}),t.top.location.hash!==t.location.hash&&(t.top.location.hash="?_p="+n.token+"&"+e.getCurrentProfile()+o)},e}])}(),angular.module("org.bonitasoft.bonitable.selectable",["org.bonitasoft.bonitable"]).directive("boSelectall",function(){return{restrict:"A",require:"^bonitable",replace:!0,template:'',link:function(t,e){t.$watch(function(){return t.$indeterminate},function(t){e[0].indeterminate=t})}}}).directive("boSelector",function(){return{restrict:"A",require:"^bonitable",link:function(t,e,n,o){function r(){t.$apply()}function a(){o.unregisterSelector(l)}var i=e.controller("ngModel"),l={data:t.$eval(n.boSelector),isChecked:function(){return i&&i.$modelValue===!0||e[0].checked},setChecked:function(t){i?(i.$setViewValue(t===!0),i.$render()):e[0].checked=t}};e.on("change",r),t.$on("$destroy",a),o.registerSelector(l)}}}),angular.module("org.bonitasoft.bonitable.repeatable",["org.bonitasoft.bonitable"]).service("domAttributes",function(){this.copy=function(t,e,n){[].slice.call(t.attributes).forEach(function(o){e.setAttribute(o.name,t.getAttribute(o.name)),n&&t.removeAttribute(o.name)})}}).directive("columnTemplate",["$compile","domAttributes",function(t,e){return{restrict:"A",scope:!0,link:function(n,o,r){var a=angular.element(r.columnTemplate),i=angular.element("");e.copy(a[0],i[0],!1);var l=t(i.append(a.contents()))(n.$parent);e.copy(i[0],o[0],!0),o.append(l)}}}]).directive("boRepeatable",["$interpolate",function(t){return{require:"bonitable",restrict:"A",compile:function(e,n,o){function r(t){return null===t.th.getAttribute("data-ignore")}function a(t,e){return e[t]===!0}function i(t,e){var n=document.createElement(t);return n.setAttribute("column-template",e),n.setAttribute("ng-repeat","column in $columns | filter:$visibilityFilter"),n}var l=n[this.name]||"thead tr:last-child",s="tr[ng-repeat]",c=e[0].querySelector(l),u=e[0].querySelector(s);if(!c||!u||c.children.length!==u.children.length)throw new Error("bo-repeatable th number does not correspond to td number. please verify you html table");var d,p=[],g=u.children;[].some.call(c.children,function(t,e){return d=e,null===t.getAttribute("data-ignore")});var b=n.visibleProp||"visible";p=[].map.call(c.children,function(t,e){return{th:t,td:g[e]}}).filter(r).map(function(e){angular.element(e.th).remove(),angular.element(e.td).remove();var n={name:t(e.th.textContent)(o),header:e.th.outerHTML,cell:e.td.outerHTML};return n[b]=angular.isUndefined(e.th.getAttribute)||angular.isUndefined(e.th.getAttribute(b))||("false"===e.th.getAttribute(b)?!1:!0),n.toRemoveExpression=e.th.getAttribute("remove-column"),n});var f=i("th","{{::column.header}}"),m=i("td","{{::column.cell}}");return c.insertBefore(f,c.children[d]),u.insertBefore(m,u.children[d]),function(e){function n(n){return!(n.toRemoveExpression&&"true"===t(n.toRemoveExpression)(e))}e.$columns=p.filter(n),e.$visibilityFilter=a.bind(null,b)}}}}]).directive("repeatableConfig",function(){return{priority:2,require:"bonitable",link:function(t,e,n){t.$watch(n.repeatableConfig,function(e){var o=n.visibleProp||"visible";if(e.length!==t.$columns.length)throw new Error("repeatable-config size differ from $columns size. Please check your config attr");t.$columns.forEach(function(t,n){t[o]=e[n]})})}}}),angular.module("org.bonitasoft.bonitable.sortable",["org.bonitasoft.bonitable"]).directive("boSorter",function(){function t(t){return t?"DESC":"ASC"}function e(t,e){var n="boSorterTitle"+e.charAt()+e.substring(1).toLowerCase();return t[n]||"Sort by "+e}return{restrict:"A",require:"^bonitable",scope:!0,templateUrl:"template/sortable/sorter.tpl.html",transclude:!0,link:function(n,o,r,a){if(n.property=(r.boSorter||r.id||"").trim(),0===n.property.length)throw new Error("bo-sorter: no id found. Please specify on which property the sort is applied to or add an id");n.sortOptions=a.getOptions();var i=t(n.sortOptions.direction);n.titleSortAttr=e(r,i),n.sort=function(){n.sortOptions.property===n.property?n.sortOptions.direction=!n.sortOptions.direction:(n.sortOptions.property=n.property,n.sortOptions.direction=!1),i=t(n.sortOptions.direction),n.titleSortAttr=e(r,i),a.triggerSortHandler(n.sortOptions)}}}}),angular.module("org.bonitasoft.bonitable.storable",["org.bonitasoft.bonitable","ngStorage"]).directive("boStorable",["$localStorage",function(t){return{restrict:"A",require:"^bonitable",priority:1,link:function(e,n,o,r){var a=o.boStorable;if(!a)throw new Error("you must set a storageId to bo-storable");e.clearTableStorage=function(e){delete t[e]},t[a]||(t[a]={}),t[a].columns?e.$columns=t[a].columns:t[a].columns=null,t[a].sortOptions?(r.getOptions().property=t[a].sortOptions.property,r.getOptions().direction=t[a].sortOptions.direction):t[a].sortOptions=null,t[a].itemsPerPage?e.pagination.itemsPerPage=t[a].itemsPerPage:t[a].itemsPerPage=null,e.$watch(r.getOptions,function(e){t[a].sortOptions=e},!0),e.$watch("$columns",function(e,n){e!==n&&(t[a].columns=e)},!0),e.$watch("pagination.itemsPerPage",function(e){t[a].itemsPerPage=e},!0),r.onStorageLoaded()}}}]),angular.module("org.bonitasoft.bonitable.settings",["ui.bootstrap.dropdown","ui.bootstrap.buttons"]).directive("tableSettings",function(){return{templateUrl:"template/table-settings/tableSettings.tpl.html",replace:!0,scope:{columns:"=",sizes:"=",pageSize:"=",labelProp:"@",visibleProp:"@",updatePageSize:"&",updateVisibility:"&"},link:function(t,e,n){t.visible=n.visibleProp||"visible",t.label=n.labelProp||"name",t.isDragging=!1,t.sortableOptions={}}}}),function(t){try{t=angular.module("org.bonitasoft.templates")}catch(e){t=angular.module("org.bonitasoft.templates",[])}t.run(["$templateCache",function(t){t.put("template/sortable/sorter.tpl.html",'\n')}])}(),function(t){try{t=angular.module("org.bonitasoft.templates")}catch(e){t=angular.module("org.bonitasoft.templates",[])}t.run(["$templateCache",function(t){t.put("template/table-settings/tableSettings.tpl.html",'\n \n\n \n')}])}();
\n