diff --git a/dist/index.html b/dist/index.html index bac5d7270..dc7fb01fb 100644 --- a/dist/index.html +++ b/dist/index.html @@ -135,6 +135,7 @@ + @@ -156,7 +157,8 @@ DIRECTIVE_PARTIALS_URL: '/views/', MEDIA_ITEM_PARTIALS_URL: '/cms/api/partials/media_items/', CACHEBUSTER: '?' + Date.now(), - NAV_LOGO: '/images/onion.png' + NAV_LOGO: '/images/onion.png', + CMS_NAMESPACE: 'Smoove' }); angular.module('bulbsCmsApp').constant('IMAGE_SERVER_URL', 'http://localimages.avclub.com'); @@ -175,13 +177,10 @@ // ****** CMS Plugins ****** \\ angular.module('bulbsCmsApp').constant('tar_options', { - namespace: 'Woodruff', endpoint: '/ads/targeting' }); angular.module('bulbsCmsApp').constant('promo_options', { - namespace: 'Woodruff', - endpoint: '/cms/api/v1/contentlist/', upper_limits: {} }); diff --git a/dist/scripts/scripts.js b/dist/scripts/scripts.js index 97924aa1a..7065c0d57 100644 --- a/dist/scripts/scripts.js +++ b/dist/scripts/scripts.js @@ -1,3 +1,3 @@ -"use strict";angular.module("underscore",[]).value("_",window._),angular.module("NProgress",[]).value("NProgress",window.NProgress),angular.module("URLify",[]).value("URLify",window.URLify),angular.module("jquery",[]).value("$",window.$),angular.module("moment",[]).value("moment",window.moment),angular.module("bulbsCmsApp",["ngCookies","ngResource","ngSanitize","ngRoute","ui.bootstrap","ui.bootstrap.datetimepicker","restangular","BettyCropper","jquery","underscore","NProgress","URLify","moment"]).config(["$locationProvider","$routeProvider","$sceProvider","routes",function($locationProvider,$routeProvider,$sceProvider,routes){$locationProvider.html5Mode(!0),$routeProvider.when("/cms/app/list/:queue/",{templateUrl:routes.PARTIALS_URL+"contentlist.html",controller:"ContentlistCtrl",reloadOnSearch:!1}).when("/cms/app/edit/:id/",{templateUrl:routes.PARTIALS_URL+"contentedit.html",controller:"ContenteditCtrl"}).when("/cms/app/promotion/",{templateUrl:routes.PARTIALS_URL+"promotion.html",controller:"PromotionCtrl",reloadOnSearch:!1}).when("/cms/app/targeting/",{templateUrl:routes.PARTIALS_URL+"targeting-editor.html",controller:"TargetingCtrl"}).when("/cms/app/pzones/",{templateUrl:routes.PARTIALS_URL+"pzones.html",controller:"PzoneCtrl"}).otherwise({redirectTo:"/cms/app/list/published/"}),$sceProvider.enabled(!1)}]).config(["$provide",function($provide){$provide.decorator("$exceptionHandler",function($delegate){return function(exception,cause){$delegate(exception,cause),window.Raven.captureException(exception)}})}]).run(["$rootScope","$http","$cookies",function($rootScope,$http,$cookies){$http.defaults.headers.post["X-CSRFToken"]=$cookies.csrftoken;var deleteHeaders=$http.defaults.headers.delete||{};deleteHeaders["X-CSRFToken"]=$cookies.csrftoken,$http.defaults.headers.delete=deleteHeaders}]),angular.module("bulbsCmsApp").controller("ContentlistCtrl",["$scope","$http","$timeout","$location","$routeParams","$window","$q","$","_","moment","ContentApi","LOADING_IMG_SRC",function($scope,$http,$timeout,$location,$routeParams,$window,$q,$,_,moment,ContentApi,LOADING_IMG_SRC){function updateIsMyStuff(){if(!$location.search().authors)return void($scope.myStuff=!1);var authors=$location.search().authors;"string"==typeof authors&&(authors=[authors]),$scope.myStuff=1===authors.length&&authors[0]===$window.current_user?!0:!1}$scope.LOADING_IMG_SRC=LOADING_IMG_SRC,$window.document.title="AVCMS | Content",$scope.pageNumber=$location.search().page||"1",$scope.myStuff=!1,$scope.queue=$routeParams.queue||"all",$scope.search=$location.search().search;var getContentCallback=function(data){$scope.articles=data,$scope.totalItems=data.metadata.count};$scope.getContent=function(){var params={page:$scope.pageNumber};"all"!==$scope.queue&&("published"===$scope.queue?params.before=moment().format("YYYY-MM-DDTHH:mmZ"):"waiting"===$scope.queue?params.status="Waiting for Editor":"draft"===$scope.queue?params.status="Draft":"scheduled"===$scope.queue&&(params.after=moment().format("YYYY-MM-DDTHH:mmZ")));var search=$location.search();for(var prop in search)if(search.hasOwnProperty(prop)){var val=search[prop];val&&"false"!==val&&(params[prop]=val)}ContentApi.all("content").getList(params).then(getContentCallback)},updateIsMyStuff(),$scope.getContent(),$scope.$on("$routeUpdate",function(){updateIsMyStuff()}),$scope.$watch("myStuff",function(){$scope.myStuff?$("#meOnly").bootstrapSwitch("setState",!0,!0):$("#meOnly").bootstrapSwitch("setState",!1,!0)}),$("#meOnly").on("switch-change",function(e,data){var value=data.value;value===!0?($location.search().authors=[$window.current_user],$scope.getContent()):value===!1&&(delete $location.search().authors,$scope.getContent())}),$scope.goToPage=function(page){$location.search(_.extend($location.search(),{page:page})),$scope.getContent()},$scope.sort=function(sort){$location.search().ordering&&0===$location.search().ordering.indexOf(sort)&&(sort="-"+sort),$location.search(_.extend($location.search(),{ordering:sort})),$scope.getContent()},$scope.publishSuccessCbk=function(data){var i;for(i=0;i<$scope.articles.length&&$scope.articles[i].id!==data.article.id;i++);for(var field in data.response)$scope.articles[i][field]=data.response[field];return $q.when()},$scope.trashSuccessCbk=function(){$timeout(function(){$scope.getContent(),$("#confirm-trash-modal").modal("hide")},1500)},$(".expcol").click(function(e){e.preventDefault();var nS="1"===$(this).attr("state")?"0":"1",i=nS?"minus":"plus",t=nS?"Collapse":"Expand",tP=$($(this).attr("href")).find(".panel-collapse");tP.collapse("0"===$(this).attr("state")?"show":"hide"),$(this).html(' '+t+" all"),$(this).attr("state",nS),$window.picturefill()}),$("body").on("shown.bs.collapse","table tr.panel",function(){window.picturefill()}),$("#meOnly").bootstrapSwitch()}]).directive("ngConfirmClick",[function(){return{link:function(scope,element,attr){var msg=attr.ngConfirmClick||"Are you sure?",clickAction=attr.confirmedClick;element.bind("click",function(){window.confirm(msg)&&scope.$eval(clickAction)})}}}]),angular.module("bulbsCmsApp").controller("ContenteditCtrl",["$scope","$routeParams","$http","$window","$location","$timeout","$interval","$compile","$q","$modal","$","IfExistsElse","Localstoragebackup","ContentApi","ReviewApi","Login","routes",function($scope,$routeParams,$http,$window,$location,$timeout,$interval,$compile,$q,$modal,$,IfExistsElse,Localstoragebackup,ContentApi,ReviewApi,Login,routes){function getContent(){return ContentApi.one("content",$routeParams.id).get().then(getArticleCallback)}function mediaItemExistsCbkFactory(index){return function(media_item){$scope.article.ratings[index].media_item=media_item,$scope.mediaItemCallbackCounter-=1}}function mediaItemDoesNotExistCbkFactory(index){return function(){saveMediaItem(index)}}function saveMediaItem(index){var type=$scope.article.ratings[index].type,mediaItem=$scope.article.ratings[index].media_item;mediaItem=ReviewApi.restangularizeElement(null,mediaItem,type);var q;q=mediaItem.id?mediaItem.put():mediaItem.post(),q.then(function(resp){$scope.article.ratings[index].media_item=resp,$scope.mediaItemCallbackCounter-=1}).catch(saveArticleErrorCbk)}function saveToContentApi(){$("#save-article-btn").html(" Saving"),$scope.article.put().then(saveArticleSuccessCbk,saveArticleErrorCbk)}function saveArticleErrorCbk(data){return 403===data.status?(Login.showLoginModal(),void $("#save-article-btn").html("Save")):($("#save-article-btn").html(" Error!"),400===status&&($scope.errors=data),void $scope.saveArticleDeferred.reject())}function saveArticleSuccessCbk(resp){$("#save-article-btn").html(" Saved!"),setTimeout(function(){$("#save-article-btn").html("Save")},1e3),$scope.article=resp,$scope.errors=null,$location.search("rating_type",null),dirtGone(),$scope.saveArticleDeferred.resolve(resp)}function waitForDirt(){$(".edit-page").one("change input","input,div.editor",function(){window.onbeforeunload=function(){return"You have unsaved changes. Leave anyway?"}})}function dirtGone(){window.onbeforeunload=function(){}}$scope.PARTIALS_URL=routes.PARTIALS_URL,$scope.CONTENT_PARTIALS_URL=routes.CONTENT_PARTIALS_URL,$scope.MEDIA_ITEM_PARTIALS_URL=routes.MEDIA_ITEM_PARTIALS_URL,$scope.CACHEBUSTER=routes.CACHEBUSTER;var getArticleCallback=function(data){$window.article=$scope.article=data,!$location.search().rating_type||data.ratings&&0!==data.ratings.length||($scope.article.ratings=[{type:$location.search().rating_type}]),$scope.$watch("article.detail_image.id",function(newVal,oldVal){$scope.article&&(newVal&&oldVal&&newVal===oldVal||null!==newVal&&(!$scope.article.image||!$scope.article.image.id||newVal&&oldVal&&$scope.article.image&&$scope.article.image.id&&oldVal===$scope.article.image.id||!oldVal&&newVal)&&($scope.article.image={id:newVal,alt:null,caption:null}))})};getContent(),$scope.$watch("article.title",function(){$window.document.title="AVCMS | Editing "+($scope.article&&$(""+$scope.article.title+"").text())}),$("body").removeClass(),$scope.tagDisplayFn=function(o){return o.name},$scope.tagCallback=function(o,input,freeForm){var tagVal=freeForm?o:o.name;IfExistsElse.ifExistsElse(ContentApi.all("tag").getList({ordering:"name",search:tagVal}),{name:tagVal},function(tag){$scope.article.tags.push(tag)},function(value){$scope.article.tags.push({name:value.name,type:"content_tag","new":!0})},function(data,status){403===status&&Login.showLoginModal()}),$(input).val("")},$scope.sectionCallback=function(o,input,freeForm){var tagVal=freeForm?o:o.name;IfExistsElse.ifExistsElse(ContentApi.all("tag").getList({ordering:"name",search:tagVal}),{name:tagVal},function(tag){$scope.article.tags.push(tag)},function(){console.log("Can't create sections.")},function(data,status){403===status&&Login.showLoginModal()}),$(input).val("")},$scope.removeTag=function(e){var tag=$(e.target).parents("[data-tag]").data("tag"),id=tag.id,newtags=[];for(var i in $scope.article.tags)$scope.article.tags[i].id!==id&&newtags.push($scope.article.tags[i]);$scope.article.tags=newtags},$scope.removeAuthor=function(e){var author=$(e.target).parents("[data-author]").data("author"),id=author.id,newauthors=[];for(var i in $scope.article.authors)$scope.article.authors[i].id!==id&&newauthors.push($scope.article.authors[i]);$scope.article.authors=newauthors},$scope.featureTypeDisplayFn=function(o){return o.name},$scope.featureTypeCallback=function(o,input,freeForm){var fVal=freeForm?o:o.name;IfExistsElse.ifExistsElse(ContentApi.all("things").getList({type:"feature_type",q:fVal}),{name:fVal},function(ft){$scope.article.feature_type=ft.name,$("#feature-type-container").removeClass("newtag")},function(value){$scope.article.feature_type=value.name,$("#feature-type-container").addClass("newtag")},function(data,status){403===status&&Login.showLoginModal()})},$scope.authorDisplayFn=function(o){return o.first_name&&o.last_name&&o.first_name+" "+o.last_name||"username: "+o.username},$scope.authorCallback=function(o,input){for(var t in $scope.article.authors)if($scope.article.authors[t].id===o.id)return;$scope.article.authors.push(o),$(input).val("")},$scope.saveArticleDeferred=$q.defer(),$scope.mediaItemCallbackCounter=void 0,$scope.$watch("mediaItemCallbackCounter",function(){0===$scope.mediaItemCallbackCounter&&saveToContentApi()}),$scope.saveArticle=function(){return Localstoragebackup.backupToLocalStorage(),ContentApi.one("content",$routeParams.id).get().then(function(data){console.log(data),data.last_modified&&$scope.article.last_modified&&moment(data.last_modified)>moment($scope.article.last_modified)?($scope.saveArticleDeferred.reject(),$modal.open({templateUrl:routes.PARTIALS_URL+"modals/last-modified-guard-modal.html",controller:"LastmodifiedguardmodalCtrl",scope:$scope,resolve:{articleOnPage:function(){return $scope.article},articleOnServer:function(){return data}}})):$scope.postValidationSaveArticle()}),$scope.saveArticleDeferred.promise},$scope.postValidationSaveArticle=function(){var data=$scope.article;$scope.article.title=$scope.editors.content_title_editor.getContent(),"Published"!==$scope.article.status&&($scope.article.slug=$window.URLify($scope.article.title,50)),$scope.article.subhead=$scope.editors.content_subhead_editor.getContent(),$scope.editors.content_body_editor&&($scope.article.body=$scope.editors.content_body_editor.getContent()),$scope.mediaItemCallbackCounter=data.ratings&&data.ratings.length||saveToContentApi();for(var i in data.ratings){var show;if("tvseason"===data.ratings[i].type){var identifier=data.ratings[i].media_item.identifier;show=data.ratings[i].media_item.show,IfExistsElse.ifExistsElse(ReviewApi.all("tvseason").getList({season:identifier,show:show}),{identifier:identifier,show:show},mediaItemExistsCbkFactory(i),mediaItemDoesNotExistCbkFactory(i),saveArticleErrorCbk)}else if("tvepisode"===data.ratings[i].type){show=data.ratings[i].media_item.show;var season=data.ratings[i].media_item.season,episode=data.ratings[i].media_item.episode;IfExistsElse.ifExistsElse(ReviewApi.all("tvepisode").getList({show:show,season:season,episode:episode}),{show:show,season:season,episode:episode},mediaItemExistsCbkFactory(i),mediaItemDoesNotExistCbkFactory(i),saveArticleErrorCbk)}else saveMediaItem(i)}return $scope.saveArticleDeferred.promise},$scope.displayAuthorAutocomplete=function(obj){return obj.first_name+" "+obj.last_name},waitForDirt(),$("#extra-info-modal").on("shown.bs.modal",function(){$window.picturefill()}),$scope.initEditor=function(name,id,options,articleField){$scope.editors=$scope.editors||{},$scope.editors[name]=new window.Editor(options),angular.element(id+" .editor").bind("input",function(){$scope.article[articleField]=$scope.editors[name].getContent()})},$window.initEditor=$scope.initEditor,$scope.$on("$destroy",function(){for(var editor in $scope.editors)$scope.editors[editor].destroy()}),$scope.addRating=function(type){$scope.article.ratings.push({grade:"",type:type,media_item:{type:type}}),$("#add-review-modal").modal("hide")},$scope.deleteRating=function(index){$scope.article.ratings.splice(index,1)},$scope.publishSuccessCbk=function(){return getContent()},$scope.trashSuccessCbk=function(){$timeout(function(){$window.history.back()},1500)};!function(){var interval=6e4;return $interval(Localstoragebackup.backupToLocalStorage,interval)}()}]),angular.module("bulbsCmsApp").controller("NavCtrl",["$scope","routes",function($scope,routes){$scope.PARTIALS_URL=routes.PARTIALS_URL,$scope.NAV_LOGO=routes.NAV_LOGO}]),angular.module("bulbsCmsApp").controller("PromotionCtrl",["$scope","$http","$window","$location","$","ContentApi","PromotionApi","promo_options",function($scope,$http,$window,$location,$,ContentApi,PromotionApi,promo_options){$window.document.title=promo_options.namespace+" | Promotion Tool",$scope.$watch("pzone",function(pzone){$scope.promotedArticles=pzone&&pzone.content&&pzone.content.length?pzone.content.slice(0):[{hey_checkthis:!0,title:"Nothing Promoted!",feature_type:"Click an article on the right and use 'Insert'"}]}),$scope.getPzones=function(){ContentApi.all("contentlist").getList().then(function(data){$scope.pzones=data,$scope.pzone=data[0]}).catch(function(){alert("Content list does not exist.")})};var getContentCallback=function(data){$scope.articles=data,$scope.totalItems=data.metadata.count};$scope.getContent=function(){var params={published:!0},search=$location.search();for(var prop in search)if(search.hasOwnProperty(prop)){var val=search[prop];val&&"false"!==val&&(params[prop]=val)}ContentApi.all("content").getList(params).then(getContentCallback)},$scope.$on("$viewContentLoaded",function(){$scope.getPzones(),$scope.getContent()}),$scope.articleIsInPromotedArticles=function(id){if($scope.promotedArticles)for(var i in $scope.promotedArticles)if($scope.promotedArticles[i].id===id)return!0;return!1};var pA=$(".promotion-area"),pC=$(".promotion-container");$scope.insertArticleMode=function(article){$scope.selectedArticle=article,pA.addClass("select-mode"),pC.off("click"),pC.on("click",".promotion-area.select-mode .article-container",function(){var index=$(this).parents("[data-index]").data("index")-0;$scope.insertArticle(index),pA.removeClass("select-mode"),$scope.$apply()})},$scope.insertArticle=function(index){var limit=promo_options.upper_limits[$scope.pzone.name];$scope.promotedArticles[index]&&$scope.promotedArticles[index].id?$scope.promotedArticles.splice(index,0,$scope.selectedArticle):$scope.promotedArticles.splice(index,1,$scope.selectedArticle),limit&&$scope.promotedArticles.length>limit&&$scope.promotedArticles.pop($scope.promotedArticles.length)},$scope.replaceArticleMode=function(article){$scope.selectedArticle=article,pA.addClass("select-mode"),pC.off("click"),pC.on("click",".promotion-area.select-mode .article-container",function(){var index=$(this).parents("[data-index]").data("index");$scope.replaceArticle(index),pA.removeClass("select-mode"),$scope.$apply()})},$scope.replaceArticle=function(index){$scope.promotedArticles.splice(index,1,$scope.selectedArticle)},$scope.save=function(){var items=$scope.promotedArticles.slice(0);items[0].id||items.shift(),$(".save-button").html(' Saving');var payload=$scope.pzone;payload.content=$scope.promotedArticles[0].hey_checkthis?[]:$scope.promotedArticles;var pzone=ContentApi.restangularizeElement(null,payload,"contentlist");return pzone.put()},$scope.moveUp=function(index){if(0!==index){var toMove=$scope.promotedArticles[index];$scope.promotedArticles[index]=$scope.promotedArticles[index-1],$scope.promotedArticles[index-1]=toMove}},$scope.moveDown=function(index){if(index!==$scope.promotedArticles.length-1){var toMove=$scope.promotedArticles[index];$scope.promotedArticles[index]=$scope.promotedArticles[index+1],$scope.promotedArticles[index+1]=toMove}},$scope.remove=function(index){$scope.promotedArticles.splice(index,1)},$("body").on("shown.bs.collapse","#page-prev .collapse",function(){$window.picturefill()})}]),angular.module("bulbsCmsApp").controller("PzoneCtrl",["$scope","$http","$window","$","ContentApi","PromotionApi","routes",function($scope,$http,$window,$,ContentApi,PromotionApi,routes){function getPzone(){PromotionApi.one("pzone/"+$scope.pzoneName).get().then(function(data){$scope.pzone=data}).catch(function(){console.log("Zone does not exist.")})}$window.document.title="AVCMS | Pzone Editor",$scope.pzoneName="homepage-one",$scope.newContentId=null,$scope.$watch("pzoneName",function(){getPzone()}),$scope.typeChanged=function(){console.log("Type changed!"),void 0!==$scope.pzone&&($scope.pzone.data={})};var getContentCallback=function(data){$scope.articles=data,$scope.totalItems=data.metadata.count};$scope.getContent=function(){ContentApi.getList("content").then(getContentCallback)},$scope.getContent(),$scope.getPZoneTemplate=function(){return routes.PARTIALS_URL+"pzones/"+$scope.pzone.zone_type+".html"},$scope.remove=function(contentId){var index=$scope.pzone.data.content_ids.indexOf(contentId);-1!==index&&$scope.pzone.data.content_ids.splice(index,1)},$scope.add=function(prepend){void 0===$scope.pzone.data.content_ids&&($scope.pzone.data.content_ids=[]),prepend&&$scope.newContentIdPrepend?$scope.pzone.data.content_ids.unshift($scope.newContentIdPrepend):$scope.newContentId&&$scope.pzone.data.content_ids.push($scope.newContentId),$scope.newContentId=null,$scope.newContentIdPrepend=null},$scope.save=function(){$("#save-pzone-btn").html(' Saving');var pzone=ContentApi.restangularizeElement(null,$scope.pzone,"pzone/"+$scope.pzoneName);pzone.put().then(function(){$("#save-pzone-btn").html(' Saved!'),window.setTimeout(function(){$("#save-pzone-btn").html("Save")},2e3)}).catch(function(){$("#save-pzone-btn").html(' Saved!'),window.setTimeout(function(){$("#save-pzone-btn").html("Save")},2e3)})}}]),angular.module("bulbsCmsApp").controller("TargetingCtrl",["$scope","$http","$window","$q","$location","tar_options","NProgress",function($scope,$http,$window,$q,$location,tar_options,NProgress){$window.document.title=tar_options.namespace+" | Targeting Editor",NProgress.configure({minimum:.4});var canceller;$scope.search=function(url){url&&("undefined"==typeof canceller?canceller=$q.defer():(canceller.resolve(),NProgress.set(0),canceller=$q.defer()),NProgress.start(),$http({method:"GET",url:tar_options.endpoint,timeout:canceller.promise,params:{url:$scope.url}}).success(function(data){$scope.targetingArray=[];for(var k in data)$scope.targetingArray.push([k,data[k]]);NProgress.done()}).error(function(data,status){404==status&&($scope.targetingArray=[],$scope.targetingArray.push(["",""]),NProgress.done())}))},$scope.save=function(){var data={};for(var i in $scope.targetingArray)data[$scope.targetingArray[i][0]]=$scope.targetingArray[i][1];return $http({method:"POST",url:tar_options.endpoint+"?url="+$scope.url,data:data})},$scope.keyHandler=function(event,url){13===event.keyCode?this.search(url):27===event.keyCode&&(event.currentTarget.value="")};var search=$location.search();search&&search.url&&($scope.url=decodeURIComponent(search.url))}]),angular.module("bulbsCmsApp").controller("ContentworkflowCtrl",["$scope","$http","$modal","$window","moment","routes","TIMEZONE_LABEL",function($scope,$http,$modal,$window,moment,routes,TIMEZONE_LABEL){$scope.TIMEZONE_LABEL=TIMEZONE_LABEL,$scope.trashContentModal=function(articleId){return $modal.open({templateUrl:routes.PARTIALS_URL+"modals/confirm-trash-modal.html",controller:"TrashcontentmodalCtrl",scope:$scope,resolve:{articleId:function(){return articleId}}})},$scope.pubTimeModal=function(article){return $modal.open({templateUrl:routes.PARTIALS_URL+"modals/choose-date-modal.html",controller:"PubtimemodalCtrl",scope:$scope,resolve:{article:function(){return article}}})},$scope.sendToEditorModal=function(article){return $modal.open({templateUrl:routes.PARTIALS_URL+"modals/send-to-editor-modal.html",controller:"SendtoeditormodalCtrl",scope:$scope,resolve:{article:function(){return article}}})},$scope.changelogModal=function(article){return $modal.open({templateUrl:routes.PARTIALS_URL+"modals/changelog-modal.html",controller:"ChangelogmodalCtrl",scope:$scope,resolve:{article:function(){return article}}})},$scope.versionBrowserModal=function(article){return $modal.open({templateUrl:routes.PARTIALS_URL+"modals/version-browser-modal.html",controller:"VersionbrowsermodalCtrl",scope:$scope,size:"lg",resolve:{article:function(){return article}}})},$scope.getStatus=function(article){return article&&article.published?moment(article.published)>moment()?"scheduled":"published":"unpublished"}}]),angular.module("bulbsCmsApp").controller("TrashcontentmodalCtrl",["$scope","$http","$modalInstance","$","Login","articleId",function($scope,$http,$modalInstance,$,Login,articleId){console.log("trash content modal ctrl here"),console.log(articleId),$scope.deleteButton={idle:"Delete",busy:"Trashing",finished:"Trashed",error:"Error!"},$scope.trashContent=function(){return console.log("trash content here"),$http({method:"POST",url:"/cms/api/v1/content/"+articleId+"/trash/"})},$scope.trashCbk=function(trash_promise){trash_promise.then(function(){console.log("trash success"),$scope.trashSuccessCbk(),$modalInstance.close()}).catch(function(reason){404===reason.status?($scope.trashSuccessCbk(),$modalInstance.close()):403===status&&(Login.showLoginModal(),$modalInstance.dismiss())})}}]),angular.module("bulbsCmsApp").controller("PubtimemodalCtrl",["$scope","$http","$modal","$modalInstance","$","moment","Login","routes","article","TIMEZONE_OFFSET",function($scope,$http,$modal,$modalInstance,$,moment,Login,routes,article,TIMEZONE_OFFSET){$scope.article=article,$scope.pubButton={idle:"Publish",busy:"Publishing",finished:"Published!",error:"Error!"},$scope.$watch("pickerValue",function(newVal){var pubTimeMoment=moment(newVal).zone(TIMEZONE_OFFSET);$scope.datePickerValue=moment().year(pubTimeMoment.year()).month(pubTimeMoment.month()).date(pubTimeMoment.date()),$scope.timePickerValue=moment().hour(pubTimeMoment.hour()).minute(pubTimeMoment.minute())});var modelDateFormat="YYYY-MM-DDTHH:mmZ";$scope.setTimeShortcut=function(shortcut){if("now"==shortcut){var now=moment().zone(TIMEZONE_OFFSET);$scope.pickerValue=now}if("midnight"==shortcut){var midnight=moment().zone(TIMEZONE_OFFSET).hour(24).minute(0);$scope.pickerValue=midnight}},$scope.setDateShortcut=function(shortcut){var today=moment().zone(TIMEZONE_OFFSET);"today"==shortcut&&($scope.datePickerValue=moment().year(today.year()).month(today.month()).date(today.date())),"tomorrow"==shortcut&&($scope.datePickerValue=moment().year(today.year()).month(today.month()).date(today.date()+1))},$scope.setPubTime=function(){if(!$scope.article.feature_type)return $modalInstance.dismiss(),void $modal.open({templateUrl:routes.PARTIALS_URL+"modals/pubtime-validation-modal.html"});var newDate=moment($scope.datePickerValue),newTime=moment($scope.timePickerValue),newDateTime=moment().zone(TIMEZONE_OFFSET).year(newDate.year()).month(newDate.month()).date(newDate.date()).hour(newTime.hour()).minute(newTime.minute()).format(modelDateFormat),data={published:newDateTime};return $http({url:"/cms/api/v1/content/"+$scope.article.id+"/publish/",method:"POST",data:data})},$scope.setPubTimeCbk=function(publish_promise){publish_promise.then(function(result){$scope.article.published=result.data.published,$scope.publishSuccessCbk&&$scope.publishSuccessCbk({article:$scope.article,response:result.data}),$modalInstance.close()}).catch(function(reason){403===reason.status&&Login.showLoginModal(),$modalInstance.dismiss()})},$scope.article.published?$scope.pickerValue=moment($scope.article.published):$scope.setTimeShortcut("now")}]),angular.module("bulbsCmsApp").controller("ImageCropModalCtrl",["$scope","$timeout","$modalInstance","BettyCropper","id",function($scope,$timeout,$modalInstance,BettyCropper,id){$scope.cropMode=!1,$scope.thumb={height:180,width:180},$scope.preview_thumb={height:110,width:110},$scope.crop_image_width=550,$scope.image_url=BettyCropper.origJpg(id,$scope.crop_image_width),$scope.preview_style={};var setupCropper=function(){$("#crop-image").Jcrop({allowSelect:!1,allowMove:!0,allowResize:!0,keySupport:!1},function(){$scope.jcrop_api=this,$scope.selectedCrop=[$scope.ratioOrder[$scope.currentCrop],$scope.image.selections[$scope.ratioOrder[$scope.currentCrop]]]})};$scope.processJcropSelection=function(s){if(angular.isNumber(s.x)&&!isNaN(s.x)||angular.isNumber(s.y)&&!isNaN(s.y)||angular.isNumber(s.x2)&&!isNaN(s.x2)||angular.isNumber(s.y2)&&!isNaN(s.y2)||angular.isNumber(s.w)&&!isNaN(s.w)||angular.isNumber(s.h)&&!isNaN(s.h)){var selection={},scale=$scope.crop_image_width/$scope.image.width;selection.x0=$scope.scaleNumber(s.x,1/scale),selection.y0=$scope.scaleNumber(s.y,1/scale),selection.x1=$scope.scaleNumber(s.x2,1/scale),selection.y1=$scope.scaleNumber(s.y2,1/scale),$scope.image.selections[$scope.selectedCrop[0]]=selection,$scope.thumb_styles[$scope.selectedCrop[0]]=$scope.computeThumbStyle($scope.image,$scope.thumb,selection),$scope.preview_style=$scope.computeThumbStyle($scope.image,$scope.preview_thumb,selection)}},$scope.setSelectedCrop=function(ratio,selection){$scope.cropMode=!0,angular.isUndefined($scope.jcrop_api)?$timeout(setupCropper,0).then(function(){$scope.selectedCrop=[ratio,selection]}):$scope.selectedCrop=[ratio,selection]},$scope.$watch("selectedCrop",function(newVal){if(!angular.isUndefined(newVal)){$scope.preview_style=$scope.computeThumbStyle($scope.image,$scope.preview_thumb,newVal[1]);var scale=$scope.crop_image_width/$scope.image.width,selection=newVal[1],ratioNums=newVal[0].split("x");$scope.jcrop_api.setOptions({aspectRatio:ratioNums[0]/ratioNums[1]}),$scope.jcrop_api.setSelect([$scope.scaleNumber(selection.x0,scale),$scope.scaleNumber(selection.y0,scale),$scope.scaleNumber(selection.x1,scale),$scope.scaleNumber(selection.y1,scale)])}}),$scope.setThumbStyles=function(image,selections){$scope.thumb_styles=$scope.thumb_styles||{};for(var ratio in selections)$scope.thumb_styles[ratio]=$scope.computeThumbStyle(image,$scope.thumb,selections[ratio])},$scope.computeThumbStyle=function(image,thumb,selection){var scale,styles,h_or_w,selection_length,s_width=selection.x1-selection.x0,s_height=selection.y1-selection.y0;return s_height>s_width?(h_or_w="height",selection_length=s_height):(h_or_w="width",selection_length=s_width),styles={},scale=thumb[h_or_w]/selection_length,styles.background="url("+$scope.image_url+")",styles["background-size"]=$scope.scaleNumber($scope.image.width,scale)+"px",styles["background-position"]="-"+$scope.scaleNumber(selection.x0,scale)+"px -"+$scope.scaleNumber(selection.y0,scale)+"px",styles["background-repeat"]="no-repeat",styles.height=$scope.scaleNumber(s_height,scale)+"px",styles.width=$scope.scaleNumber(s_width,scale)+"px",styles.top="50%",styles["margin-top"]="-"+$scope.scaleNumber(s_height,scale)/2+"px",styles},$scope.scaleNumber=function(num,by_scale){return Math.floor(num*by_scale)},$scope.cancel=function(){$modalInstance.dismiss("cancel")},$scope.back=function(){$scope.cropMode=!1},$scope.saveAndQuit=function(){$scope.processJcropSelection($scope.jcrop_api.tellSelect()),BettyCropper.updateSelection($scope.image.id,$scope.selectedCrop[0],$scope.image.selections[$scope.selectedCrop[0]]).success(function(){$modalInstance.close()})},$scope.saveAndNext=function(){$scope.processJcropSelection($scope.jcrop_api.tellSelect()),BettyCropper.updateSelection($scope.image.id,$scope.selectedCrop[0],$scope.image.selections[$scope.selectedCrop[0]]).success(function(){var next=$scope.currentCrop+1;next>=$scope.ratioOrder.length&&(next=0),$scope.currentCrop=next,$scope.selectedCrop=[$scope.ratioOrder[$scope.currentCrop],$scope.image.selections[$scope.ratioOrder[$scope.currentCrop]]]})},$scope.isCurrentCrop=function(ratio){return $scope.ratioOrder[$scope.currentCrop]===ratio?{color:"#5bc0de"}:void 0},$scope.onInit=function(){BettyCropper.detail(id).success(function(data){$scope.image=data,$scope.setThumbStyles($scope.image,$scope.image.selections),$scope.ratioOrder=Object.keys($scope.image.selections),$scope.currentCrop=0})},$scope.onInit()}]),angular.module("bulbsCmsApp").controller("LoginmodalCtrl",["$scope","Login","$modalInstance","$",function($scope,Login,$modalInstance,$){$scope.login=function(){var username=$("input[name='username']").val(),password=$("input[name='password']").val();Login.login(username,password).then(function(){$modalInstance.close()},function(){$modalInstance.dismiss()})}}]),angular.module("bulbsCmsApp").controller("UnpublishCtrl",["$scope","$http","$q",function($scope,$http,$q){$scope.unpublish=function(article){var data={published:!1},deferred=$q.defer();return $http({url:"/cms/api/v1/content/"+article.id+"/publish/",method:"POST",data:data}).success(function(data){deferred.resolve({article:article,response:data})}).error(function(data){deferred.reject(data)}),deferred.promise}}]),angular.module("bulbsCmsApp").directive("activeNav",["$location",function($location){return{template:'
  • {{label}}
  • ',restrict:"E",scope:{},replace:!0,link:function(scope,element,attrs){scope.href=attrs.href,scope.label=attrs.label,0===$location.path().indexOf(scope.href)&&element.addClass("active")}}}]),angular.module("bulbsCmsApp").directive("articlecontainer",["routes","LOADING_IMG_SRC",function(routes,LOADING_IMG_SRC){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"promotion-tool-article-container.html",scope:{article:"="},link:function(scope,element,attrs){scope.LOADING_IMG_SRC=LOADING_IMG_SRC,scope.ratio=attrs.ratio}}}]),angular.module("bulbsCmsApp").directive("bulbsAutocomplete",["$http","$location","$compile","$timeout","$","Login",function($http,$location,$compile,$timeout,$,Login){return{restrict:"A",scope:!0,link:function(scope,element,attrs){function getAutocompletes(val){$timeout.cancel(inputTimeout),inputCounter=0,$http({method:"GET",url:attrs.resourceUrl+val}).success(function(data){var results=data.results||data;scope.autocomplete_list=results.splice(0,5)}).error(function(data,status){403===status&&Login.showLoginModal()})}scope.displayfn=scope[attrs.displayfn],scope.callback=scope[attrs.callback];var $elem=$(element).find("input");$elem.attr("autocomplete","off");var dropdown=$($compile($("#autocomplete-dropdown-template").html())(scope));$(dropdown).css({position:"absolute",top:$elem.position().top+$elem.outerHeight(),left:$elem.position().left,minWidth:$elem.outerWidth(),display:"none"}),$elem.parent().append(dropdown),$(dropdown).fadeIn("fast"),scope.$watch(function(){return{top:$elem.position().top+$elem.outerHeight(),left:$elem.position().left,minWidth:$elem.outerWidth()}},function(newValue){$(dropdown).css({top:newValue.top,left:newValue.left,minWidth:newValue.minWidth})},!0); -var inputTimeout,inputCounter=0;$elem.on("focus",function(){$elem.on("input",function(){var val=$elem.val();""===val?scope.autocomplete_list=[]:($timeout.cancel(inputTimeout),inputTimeout=$timeout(function(){getAutocompletes(val)},200),inputCounter>2&&getAutocompletes(val))}),$(dropdown).fadeIn("fast")}),scope.blurTimeout,$elem.on("blur",function(){$(dropdown).fadeOut("fast")}),$(dropdown).on("mouseover",".entry",function(){$(dropdown).find(".selected").removeClass("selected"),$(this).addClass("selected")}),$elem.on("keyup",function(e){if(40===e.keyCode)if(0===$("div.selected",dropdown).length)$("div.entry",dropdown).first().addClass("selected");else{var curDownSelect=$("div.selected",dropdown),curDownSelectNext=curDownSelect.next("div");0===curDownSelectNext.length?$("div.entry",dropdown).first().addClass("selected"):curDownSelectNext.addClass("selected"),curDownSelect.removeClass("selected")}if(38===e.keyCode)if(0===$("div.selected",dropdown).length)$("div.entry",dropdown).last().addClass("selected");else{var curSelect=$("div.selected",dropdown),curSelectNext=curSelect.prev("div");0===curSelectNext.length?$("div.entry",dropdown).last().addClass("selected"):curSelectNext.addClass("selected"),curSelect.removeClass("selected")}if(13===e.keyCode){var selected=$("div.selected",dropdown);0===selected.length&&scope.onClick($elem.val(),!0),selected.click()}}),scope.onClick=function(o,freeForm){scope.callback(o,$elem,freeForm||!1),scope.autocomplete_list=[]}}}}]),angular.module("bulbsCmsApp").directive("bettyeditable",["$http","routes","BettyCropper","openImageCropModal",function($http,routes,BettyCropper,openImageCropModal){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"bettyeditable.html",scope:{image:"=",addStyles:"@",placeholderText:"@",ratio:"@"},controller:["$scope","$element",function($scope){$scope.imageData=null,$scope.uploadSuccess=function(response){$scope.image||($scope.image={id:null,caption:null,alt:null}),$scope.image.id=response.id,$scope.imageData=response,$scope.showImage()},$scope.upload=function(){if(1!=this.files.length)return void console.log("We need exactly one image!");var file=this.files[0];if(0!=file.type.indexOf("image/"))return void console.log("Not an image!");file.size>68e5&&console.log("The file is too large!");var imageData=new FormData;imageData.append("image",file),BettyCropper.new(file).success($scope.uploadSuccess)}}],link:function(scope,element){var input=element.find("input");input.on("change",scope.upload);var DEFAULT_IMAGE_WIDTH=1200,ratioWidth=parseInt(scope.ratio.split("x")[0],10),ratioHeight=parseInt(scope.ratio.split("x")[1],10);scope.uploadFile=function(){input[0].click()},scope.showImage=function(){return null===scope.imageData?(console.log("Getting selections!"),void scope.getImageData()):void(scope.imageStyling=scope.computeImageStyle(scope.imageData,scope.imageData.selections[scope.ratio]))},scope.computeImageStyle=function(image,selection){var scale,styles,el_height=image.height/image.width*$(element).parent().width(),s_width=selection.x1-selection.x0,s_height=selection.y1-selection.y0,tmp_selection=selection;return s_width&&s_height||(s_width=$(element).parent().width(),s_height=el_height,tmp_selection={x0:0,y0:0,x1:s_width,y1:s_height}),styles={},scale=$(element).parent().width()/s_width,styles.background="url("+BettyCropper.origJpg(scope.image.id,DEFAULT_IMAGE_WIDTH)+")",styles["background-size"]=scope.scaleNumber(image.width,scale)+"px",styles["background-position"]="-"+scope.scaleNumber(tmp_selection.x0,scale)+"px -"+scope.scaleNumber(tmp_selection.y0,scale)+"px",styles["background-repeat"]="no-repeat",styles.height=scope.scaleNumber(s_height,scale)+"px",styles.width=scope.scaleNumber(s_width,scale)+"px",styles.position="relative",styles},scope.scaleNumber=function(num,by_scale){return Math.floor(num*by_scale)},scope.getImageData=function(){BettyCropper.detail(scope.image.id).success(function(response){scope.imageData=response,scope.showImage()}).error(function(data,status){if(404===status){var el_Height=ratioHeight/ratioWidth*$(element).parent().width();scope.imageStyling={background:"url("+BettyCropper.url(scope.image.id,scope.ratio,DEFAULT_IMAGE_WIDTH,"jpg")+")","background-size":$(element).parent().width(),height:Math.floor(el_Height)+"px",position:"relative"}}})},scope.removeImage=function(){scope.image=null},scope.editImage=function(){openImageCropModal(scope.image.id).then(function(){scope.getImageData()})},scope.image&&scope.showImage()}}}]),angular.module("bulbsCmsApp").directive("bettyimage",["$http","routes",function($http,routes){return{replace:!0,restrict:"E",templateUrl:routes.PARTIALS_URL+"bettyimage.html",scope:{image:"=",ratio:"=",width:"@"},controller:["$scope",function(){}],link:function(scope,element){scope.width=parseInt(scope.width,10);{var ratioWidth=parseInt(scope.ratio.split("x")[0],10),ratioHeight=parseInt(scope.ratio.split("x")[1],10);scope.width*ratioHeight/ratioWidth+"px"}element.css("width",scope.width+"px"),element.css("height",scope.width*ratioHeight/ratioWidth+"px");var selection=scope.image.selections[scope.ratio],selectionWidth=selection.x1-selection.x0,scale=scope.width/selectionWidth,requestWidth=Math.round(scale*(scope.image.width-selectionWidth)+scope.width);element.css("background-image","url("+routes.IMAGE_SERVER_URL+"/"+scope.image.id+"/original/"+requestWidth+".jpg)"),element.css("background-position",scale*selection.x0*-1+"px "+scale*selection.y0*-1+"px")}}}]),angular.module("bulbsCmsApp").directive("createContent",["$http","$window","$","IfExistsElse","Login","ContentApi","routes",function($http,$window,$,IfExistsElse,Login,ContentApi,routes){return{restrict:"E",templateUrl:routes.DIRECTIVE_PARTIALS_URL+"create-content.html",controller:["$scope",function($scope){function saveArticle(){$("button.go").html(' Going'),$http({url:"/cms/api/v1/content/?doctype="+$scope.contentType,method:"POST",data:$scope.init}).success(function(resp){var new_id=resp.id,new_path="/cms/app/edit/"+new_id+"/";$scope.rating_type&&(new_path+="?rating_type="+$scope.rating_type),$window.location.href=$window.location.origin+new_path}).error(function(data,status){$("button.go").html(403===status?' Please Login':' Error!'),$scope.gotSave=!1})}$scope.gotTags=!1,$scope.gotUser=!1,$scope.gotSave=!1,$scope.$watch(function(){return $scope.gotTags&&$scope.gotUser&&$scope.gotSave},function(val){val&&saveArticle($scope.init)}),$scope.newArticle=function(){var init={title:$scope.newTitle};angular.extend($scope.init,init),$scope.tag?IfExistsElse.ifExistsElse(ContentApi.all("tag").getList({ordering:"name",search:$scope.tag}),{slug:$scope.tag},function(tag){$scope.init.tags=[tag],$scope.gotTags=!0},function(value){console.log("couldnt find tag "+value.slug+" for initial value")},function(data,status){403===status&&Login.showLoginModal()}):$scope.gotTags=!0,$http.get("/users/me/").then(function(data){$scope.init.authors=[data.data],$scope.gotUser=!0}),$scope.gotSave=!0}}],link:function(scope,element){$(element).find("a.create-content").on("click",function(){$("a.create-content.active").removeClass("active"),$(this).addClass("active")}),$(element).find("a.create-content").on("click",function(){return scope.contentTypeLabel=$(this).text(),scope.contentType=$(this).data("content_type")||null,scope.init=$(this).data("init")||{},scope.tag=$(this).data("tag")||null,scope.rating_type=$(this).data("rating_type")||null,scope.$apply(),$(this).hasClass("go-next")&&$("#create button.next-pane").click(),!0}),$("button.next-pane:not(.hide)").on("click",function(){console.log("next clicked"),console.log(scope.contentType),console.log(scope.init),$("#createcontent-01").addClass("hidden"),$("#createcontent-02").removeClass("hidden"),$("button.next-pane:not(.hide)").addClass("hidden"),$(".new-title").focus()}),$(element).find(".new-title").on("keydown",function(e){13===e.keyCode&&$(element).find(".go").click()})}}}]),angular.module("bulbsCmsApp").directive("devicepreview",["$","routes",function($,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"devicepreview.html",link:function(){var pP=$("#page-prev"),tN=pP.find(".nav a"),cO=pP.find(".tab-content .active");tN.click(function(e){var newId=$(this).attr("href").split("#")[1];e.preventDefault(),cO.attr("id",newId)}),$("#page-prev").on("show.bs.collapse",function(){$(this).find(".fa").removeClass("fa-plus-square-o").addClass("fa-minus-square-o")}),$("#page-prev").on("hide.bs.collapse",function(){$(this).find(".fa").removeClass("fa-minus-square-o").addClass("fa-plus-square-o")})}}}]),angular.module("bulbsCmsApp").directive("filterwidget",["$http","$location","$window","$timeout","$","routes",function($http,$location,$window,$timeout,$,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"filterwidget.html",link:function(scope,element){function getAutocompletes(search){return $timeout.cancel(filterInputTimeout),filterInputCounter=0,search.length<1?(scope.autocompleteArray=[],void scope.$apply()):void $http({url:"/cms/api/v1/things/?type=tag&type=feature_type&type=author",method:"GET",params:{q:search}}).success(function(data){scope.autocompleteArray=data})}function arrowSelect(direction){var $toSelect,$entries=$element.find(".entry"),$selected=$element.find(".entry.selected");$selected.length>0?("up"===direction&&($toSelect=$selected.first().prev()),"down"===direction&&($toSelect=$selected.first().next())):("up"===direction&&($toSelect=$entries.last()),"down"===direction&&($toSelect=$entries.first())),scope.selectEntry($toSelect)}function applyFilterChange(filterObject){filterObject.page=1,$location.search(filterObject),scope.getContent(),scope.autocompleteArray=[],$input.trigger("blur")}function getFilterObjects(){var search=$location.search();if(scope.filterObjects={},"undefined"==typeof search)return void console.log("udnefined");var filterParamsToTypes={authors:"author",tags:"tag",feature_types:"feature_type"};for(var filterParam in filterParamsToTypes){var filterType=filterParamsToTypes[filterParam];"string"==typeof search[filterParam]&&(search[filterParam]=[search[filterParam]]);for(var i in search[filterParam]){var value=search[filterParam][i];scope.filterObjects[filterType+value]={query:value,type:filterParam},getQueryToLabelMappings(filterType,value)}}search.search&&(scope.filterInputValue=search.search)}function getQueryToLabelMappings(type,query){scope.queryToLabelMappings=scope.queryToLabelMappings||{},query in scope.queryToLabelMappings||$http({url:"/cms/api/v1/things/?type="+type,method:"GET",params:{q:query}}).success(function(data){for(var i in data)scope.queryToLabelMappings[data[i].value]=data[i].name})}var $element=$(element),$input=$element.find("input");scope.searchTerm,scope.autocompleteArray=[];var filterInputTimeout,filterInputCounter=0;$input.on("input",function(){var search=$input.val();scope.searchTerm=search,$timeout.cancel(filterInputTimeout),filterInputTimeout=$timeout(function(){getAutocompletes(search)},200),filterInputCounter>2&&getAutocompletes(search)}),$input.on("keyup",function(e){38===e.keyCode&&arrowSelect("up"),40===e.keyCode&&arrowSelect("down"),13===e.keyCode&&($element.find(".selected").length>0?$element.find(".selected").click():scope.addFilter("search",$input.val()))}),$element.find(".search-button").on("click",function(){scope.addFilter("search",$input.val())}),$element.find(".clear-button").on("click",function(){$(this).prev("input").val(""),scope.filterObjects={},applyFilterChange({})}),$element.on("mouseover",".entry",function(){scope.selectEntry(this)}),scope.selectEntry=function(entry){$element.find(".selected").removeClass("selected"),$(entry).addClass("selected")},$input.on("blur",function(){$element.find(".dropdown-menu").fadeOut(200)}),$input.on("focus",function(){$element.find(".dropdown-menu").fadeIn(200)}),scope.addFilter=function(type,newFilterValue){var filterObject=$location.search();"search"===type?filterObject.search=newFilterValue:(filterObject[type]||(filterObject[type]=[]),"string"==typeof filterObject[type]&&(filterObject[type]=[filterObject[type]]),filterObject[type].push(newFilterValue),$input.val("")),applyFilterChange(filterObject),scope.filterInputValue=""},scope.deleteFilter=function(key){var filterObject=$location.search(),toDelete=scope.filterObjects[key];"string"==typeof filterObject[toDelete.type]&&(filterObject[type]=[filterObject[type]]);var toSplice;for(var i in filterObject[toDelete.type])if(filterObject[toDelete.type][i]===toDelete.query){toSplice=i;break}filterObject[toDelete.type].splice(i,1),filterObject.search=$input.val(),delete scope.filterObjects[key],applyFilterChange(filterObject)},scope.$on("$routeUpdate",function(){getFilterObjects()}),getFilterObjects()}}}]),angular.module("bulbsCmsApp").directive("imagedrawer",["$http","$window","$","routes","BC_API_KEY",function($http,$window,$,routes,BC_API_KEY){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"imagedrawer.html",scope:{openImageDrawer:"=",closeImageDrawer:"=",article:"="},controller:["$scope",function($scope){function scaleSelection(scale,selection){return[Math.floor(scale*selection[0]),Math.floor(scale*selection[1]),Math.floor(scale*selection[2]),Math.floor(scale*selection[3])]}$scope.current_image={},$scope.$watch("current_image",function(){$scope.library_images=prependCurrentImage($scope.library_images,$scope.current_image)}),$scope.library_images=[];var prependCurrentImage=function(library,current_image){var new_library=library;if(current_image.id){for(var i in new_library)if(new_library[i].id===current_image.id){new_library.splice(i,1);break}new_library.unshift(current_image)}return new_library},refreshImageLibrary=function(params){params=params||{},$http({method:"GET",url:routes.BC_ADMIN_URL+"/api/search",params:params,headers:{"X-Betty-Api-Key":BC_API_KEY}}).success(function(data){$scope.library_images=prependCurrentImage(data.results,$scope.current_image)})};$scope.drawerUpload=function(){$window.uploadImage({onProgress:function(){},onSuccess:function(data){refreshImageLibrary(),$scope.onChangeFn(data),$scope.current_image=data},onError:$scope.onCancelFn,onCancel:$scope.onCancelFn})};var refreshCurrentImage=function(id,field){$http({url:routes.BC_ADMIN_URL+"/api/"+id,method:"GET",headers:{"X-Betty-Api-Key":BC_API_KEY}}).success(function(data){field?$scope.current_image[field]=data[field]:$scope.current_image=data,$window.picturefill(!0)}).error(function(){$scope.current_image={}})};$window.refreshCurrentImage=refreshCurrentImage,$scope.$watch("imageLibrarySearch",function(){refreshImageLibrary({q:$scope.imageLibrarySearch})}),$scope.openImageDrawer=function(){var oldId,onChangeFn,onSaveFn,onCancelFn;"function"==typeof arguments[0]?(oldId=null,onChangeFn=arguments[0],onSaveFn=arguments[1],onCancelFn=arguments[2]):(oldId=arguments[0],onChangeFn=arguments[1],onSaveFn=arguments[2],onCancelFn=arguments[3]),$("#image-drawer").off("click"),$("#image-drawer").on("click","#image-library.image",function(){var id=$(this).data("imageId");refreshCurrentImage(id),onChangeFn(id)}),oldId&&($scope.original_image=oldId),refreshCurrentImage(oldId),$scope.oldId=oldId,$scope.onChangeFn=onChangeFn,$scope.onSaveFn=onSaveFn,$scope.onCancelFn=function(id){$scope.original_image&&refreshCurrentImage($scope.original_image),onCancelFn(id)},$("body").addClass("image-drawer-cropper-open"),refreshImageLibrary()},$window.openImageDrawer=$scope.openImageDrawer,$scope.openImageLibrary=function(){$scope.libraryOpen=!0,$("body").addClass("image-drawer-library-open"),$window.picturefill(!0)},$scope.closeImageDrawer=function(){$("body").removeClass("image-drawer-cropper-open"),$("body").removeClass("image-drawer-library-open"),$window.picturefill()},$scope.closeImageLibrary=function(action){"save"===action&&$scope.onSaveFn(),"cancel"===action&&$scope.onCancelFn($scope.oldId),$("body").removeClass("image-drawer-library-open"),$scope.libraryOpen=!1},$scope.saveImageData=function(e){$window.saveImageData(e)},$scope.saveNewCrop=function(image,ratio){image.selections[ratio]={x0:user_selection_scaled[0],y0:user_selection_scaled[1],x1:user_selection_scaled[2],y1:user_selection_scaled[3]},$scope.$apply(),$window.saveNewCrop(image,ratio,user_selection_scaled,{onSuccess:function(){refreshCurrentImage(image.id,"selections")}})};var jcrop_api,user_selection,user_selection_scaled;$("#cropperModal").on("hidden.bs.modal",function(){jcrop_api.destroy()}),$("#cropperModal").on("shown.bs.modal",function(){$window.picturefill()}),$scope.cropImage=function(image,ratio){var width=500;$("#cropper-img").attr("src",routes.IMAGE_SERVER_URL+"/"+image.id+"/original/"+width+".jpg");var aspectWidth=ratio.split("x")[0],aspectHeight=ratio.split("x")[1],scale=width/image.width,selection=[image.selections[ratio].x0,image.selections[ratio].y0,image.selections[ratio].x1,image.selections[ratio].y1],onSelect=function(c){var selection=[c.x,c.y,c.x2,c.y2];user_selection=selection,user_selection_scaled=scaleSelection(1/scale,selection)};$("#cropper-modal-save-button").unbind("click"),$("#cropper-modal-save-button").click(function(){$scope.saveNewCrop(image,ratio)}),$("#cropperModal").modal("show"),$("#cropper-img").Jcrop({onSelect:onSelect,allowMove:!0,allowResize:!0,aspectRatio:aspectWidth/aspectHeight},function(){jcrop_api=this,jcrop_api.setOptions({aspectRatio:aspectWidth/aspectHeight}),this.focus();scaleSelection(scale,selection);this.setSelect(scaleSelection(scale,selection))})}}],link:function(scope){function preventDefault(e){e=e||window.event,e.preventDefault&&e.preventDefault(),e.returnValue=!1}scope.IMAGE_SERVER_URL=routes.IMAGE_SERVER_URL,document.getElementById("image-cropper").onmousewheel=function(e){document.getElementById("image-cropper").scrollTop-=e.wheelDeltaY,preventDefault(e)},document.getElementById("image-library-body").onmousewheel=function(e){document.getElementById("image-library-body").scrollTop-=e.wheelDeltaY,preventDefault(e)}}}}]),angular.module("bulbsCmsApp").directive("listinput",["$","routes",function($,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"listinput.html",scope:{model:"="},link:function(scope,element,attrs){scope.label=attrs.label,scope.noun=attrs.noun,element.find("input")[0].setAttribute("name",attrs.noun),element.find("input").bind("focus",function(){$(element).find(".preview").hide(),$(element).find(".all-container").show()}),element.find("input").bind("blur",function(){$(element).find(".all-container").hide(),$(element).find(".preview").show()}),element.find("input").bind("keyup",function(e){if(13===e.keyCode){var value=$(this).val();value.length>0&&(scope.model||(scope.model=[]),scope.model.push($(this).val()),scope.$apply(),$(this).val(""))}})}}}]),angular.module("bulbsCmsApp").directive("videoUpload",["$http","$window","$timeout","$sce","$","routes",function($http,$window,$timeout,$sce,$,routes){return{templateUrl:routes.PARTIALS_URL+"mainvideo.html",scope:{article:"="},restrict:"E",link:function(scope,element){function abortUpload(){setProgress(0),scope.req&&scope.req.abort(),scope.video={},setProgress(0)}function abortEncode(){$.ajax("https://app.zencoder.com/api/v2/jobs/"+scope.video.job_id+"/cancel.json?api_key="+$window.videoAttrs.zencoderApiKey,{type:"PUT",success:function(){scope.video.status=3,fakeInput.val("Encoding failed! Please try again.")}})}function setProgress(progress){return 0===progress||100===progress?void progressEl.hide():void((0===scope.lastProgress||Math.abs(progress-scope.lastProgress)>2)&&(progressBar.css("width",Math.floor(progress)+"%"),scope.lastProgress=progress,progressEl.show()))}function updateEncodeProgress(){progressBar.addClass("progress-bar-success"),delete $http.defaults.headers.common["X-Requested-With"],$http({url:"https://app.zencoder.com/api/v2/jobs/"+scope.video.job_id+"/progress.json",method:"GET",params:{api_key:$window.videoAttrs.zencoderApiKey},useXDomain:!0}).success(function(data){"waiting"===data.state||"pending"===data.state||"processing"===data.state?(scope.video.status=2,data.progress>5?(setProgress(data.progress),$timeout(updateEncodeProgress,500)):$timeout(updateEncodeProgress,2e3)):(setProgress(0),"finished"===data.state&&(scope.video.status=1),("failed"===data.state||"cancelled"===data.state)&&(scope.video.status=3,fakeInput.val("Encoding failed! Please try again.")))}).error(function(){$(".alert-danger").fadeIn().delay(1e3).fadeOut()})}console.log("video upload here"),console.log(scope.video_id),scope.$watch("article.video",function(){scope.article.video&&(scope.embedUrl=$sce.trustAsUrl("/videos/embed?id="+scope.article.video),$http({method:"GET",url:"/videos/api/video/"+scope.article.video+"/"}).success(function(data){console.log("getting video from API"),console.log(data),scope.video=data,$window.initVideoWidget(data.id)}))}),scope.$watch("video",function(){});var progressEl=(element.find("label.btn"),element.find("div.progress")),progressBar=element.find("div.progress-bar"),fakeInput=(element.find("div.progress span"),element.find("input.fake-input"));scope.lastProgress=0,scope.addVideo=function(){console.log("chooseFile"),$window.uploadVideo(element.find(".video-container")[0],{onSuccess:function(videoid){scope.$apply(function(){console.log("addVideo onSuccess callback"),console.log(videoid),scope.article.video=videoid})},onError:function(data){console.log("addVideo onError callback"),console.log(data)},onProgress:function(data){console.log("addVideo onProgress callback"),console.log(data)}})},scope.clearVideo=function(areYouSure){areYouSure?($("#s3upload-file-input").val(""),scope.article.video=null):$("#confirm-clear-video-modal").modal("show")},scope.abort=function(){return scope.encoding?void abortEncode():void abortUpload()};var initialCheckRan=!1;scope.$watch("video",function(){scope.video&&scope.video.job_id&&!initialCheckRan&&(updateEncodeProgress(),initialCheckRan=!0)})}}}]),angular.module("bulbsCmsApp").directive("mediaRating",["$http","$","routes",function($http,$,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"rating.html",scope:!0,controller:["$scope",function($scope){$scope.search=function(el){$scope.searchTimeout=null;for(var inputs=el.find(".media-field input"),searchParams={},i=0;i "+scope.config.busy);var save_promise=scope.getPromise(),promise=save_promise.then(function(result){return NProgress.done(),element.prop("disabled",!1).removeClass("btn-danger").html(" "+scope.config.finished),$timeout(function(){element.html(scope.config.idle)},1e3),result},function(reason){return NProgress.done(),element.prop("disabled",!1).addClass("btn-danger").html(" "+scope.config.error),$q.reject(reason)});scope.saveCbk&&scope.saveCbk({promise:promise})}}}}]),angular.module("bulbsCmsApp").directive("slideshowPane",["$http","$window","$compile","$","routes",function($http,$window,$compile,$,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"slideshow-pane.html",scope:{article:"=",image:"=",index:"="},link:function(scope,element,attrs){var $element=$(element);"false"===attrs.caption&&(scope.hideCaption=!0),scope.format=attrs.format||"jpg",scope.crop=attrs.crop||"16x9",scope.removeImage=function(index){scope.article.slides.splice(index,1)},scope.editImage=function(index){$window.openImageDrawer(scope.article.slides[index].id,function(data){function removeLoadingGif(){$element.find('.image img[src="'+routes.LOADING_IMG_SRC+'"]').remove()}removeLoadingGif(),$element.find(".image").data("imageId")!==data.id&&($element.find(".image img").on("load",removeLoadingGif),$element.find(".image img").after(''),scope.article.slides[index].id=data.id.toString(),scope.$apply(),$window.picturefill(),$element.find(".image img")[0].complete&&removeLoadingGif())},function(){},function(oldImage){scope.article.slides[index]=oldImage,$window.picturefill()})}}}}]),angular.module("bulbsCmsApp").directive("targeting",["routes",function(routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"targeting.html",link:function(scope){scope.addTargetingRow=function(){scope.targetingArray.push([])},scope.removeTargetingRow=function(index){scope.targetingArray.splice(index,1)}}}}]),angular.module("bulbsCmsApp").directive("titleimage",["$http","$window","$","routes",function($http,$window,$,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"titleimage.html",scope:{article:"=",image:"="},link:function(scope,element,attrs){var $element=$(element);"false"===attrs.caption&&(scope.hideCaption=!0),scope.format=attrs.format||"jpg",scope.crop=attrs.crop||"16x9",scope.placeholderText=attrs.placeholderText||"Optional Image",scope.removeTitleImage=function(){scope.image=null},scope.addTitleImage=function(){$window.uploadImage({onSuccess:function(data){scope.$apply(function(){scope.image={id:data.id.toString(),alt:null,caption:null},setTimeout($window.picturefill,200)})},onError:function(data){scope.$apply(function(){alert("Error: ",data)})},onProgress:function(){}})},scope.editTitleImage=function(){$window.openImageDrawer(scope.image.id,function(data){function removeLoadingGif(){$element.find('.image img[src="'+routes.LOADING_IMG_SRC+'"]').remove()}removeLoadingGif(),$element.find(".image").data("imageId")!==data.id&&($element.find(".image img").on("load",removeLoadingGif),$element.find(".image img").after(''),scope.image.id=data.id.toString(),scope.$apply(),$window.picturefill(),$element.find(".image img")[0].complete&&removeLoadingGif())},function(){},function(oldImage){scope.image=oldImage,$window.picturefill()})}}}}]),angular.module("bulbsCmsApp").filter("truncateByCharacters",function(){return function(input,chars,breakOnWord){if(isNaN(chars))return input;if(0>=chars)return"";if(input&&input.length>=chars){if(input=input.substring(0,chars),breakOnWord)for(;" "===input.charAt(input.length-1);)input=input.substr(0,input.length-1);else{var lastspace=input.lastIndexOf(" ");-1!==lastspace&&(input=input.substr(0,lastspace))}return 1===chars?input+".":input+"..."}return input}}),angular.module("bulbsCmsApp").filter("truncateByWords",function(){return function(input,words){if(isNaN(words))return input;if(0>=words)return"";if(input){var inputWords=input.split(/\s+/);inputWords.length>words&&(input=inputWords.slice(0,words).join(" ")+"...")}return input}}),function(global){var OnionCmsUI=OnionCmsUI||function(editor){function init(){toolbarPosition=$("#content-body .document-tools").offset().top+12,$(window).scroll(function(){window.scrollY>toolbarPosition?$("#content-body .document-tools").addClass("fixed"):$("#content-body .document-tools").removeClass("fixed")}),key("⌘+s, ctrl+s",function(e){e.preventDefault()})}var toolbarPosition;editor.on("init",init)};global.EditorModules.push(OnionCmsUI)}(this),function(global){var OnionImage=OnionImage||function(editor){function uploadImage(options){function onProgress(){}function onSuccess(data){options.onSuccess(options.block,{image_id:data.id}),window.picturefill()}function onError(){}function onCancel(){}global.uploadImage({onProgress:onProgress,onSuccess:onSuccess,onError:onError,onCancel:onCancel})}function editImage(options){function onDrawerImageChange(id){$(options.element).attr("data-image-id",id),window.picturefill()}function onDrawerSave(){}function onDrawerCancel(){}current_id=options.element.getAttribute("data-image-id"),openImageDrawer(current_id,onDrawerImageChange,onDrawerSave,onDrawerCancel)}editor.on("inline:edit:image",editImage),editor.on("inline:insert:image",uploadImage);var current_id};global.EditorModules.push(OnionImage)}(this),function(global){var OnionVideo=OnionVideo||function(editor){function cleanup(){for(var old_embeds=$("[data-type=embed] iframe[src^='/videos/embed']").parents("div.embed"),i=0;i")}editor.on("inline:insert:hr",insert)};global.EditorModules.push(HR)}(this),$(document).unbind("keydown").bind("keydown",function(event){var doPrevent=!1;if(8===event.keyCode){var d=event.srcElement||event.target;doPrevent=["TEXTAREA","INPUT"].indexOf(-1!==d.tagName.toUpperCase())?d.readOnly||d.disabled:d.isContentEditable?!1:!0}doPrevent&&event.preventDefault()}),angular.module("BettyCropper",[]).service("BettyCropper",["$http","$interpolate","IMAGE_SERVER_URL","BC_API_KEY",function($http,$interpolate,IMAGE_SERVER_URL,BC_API_KEY){this.detail=function(id){return $http({method:"GET",url:IMAGE_SERVER_URL+"/api/"+id,headers:{"X-Betty-Api-Key":BC_API_KEY,"Content-Type":void 0},transformRequest:angular.identity})},this.detailPatch=function(id,name,credit,selections){return $http({method:"PATCH",url:IMAGE_SERVER_URL+"/api/"+id,headers:{"X-Betty-Api-Key":BC_API_KEY,"Content-Type":void 0},data:{name:name,credit:credit,selections:selections},transformRequest:angular.identity})},this.new=function(image,name,credit){var imageData=new FormData;return imageData.append("image",image),name&&imageData.append("name",name),credit&&imageData.append("credit",credit),$http({method:"POST",url:IMAGE_SERVER_URL+"/api/new",headers:{"X-Betty-Api-Key":BC_API_KEY,"Content-Type":void 0},data:imageData,transformRequest:angular.identity})},this.updateSelection=function(id,ratio,selections){return $http({method:"POST",url:IMAGE_SERVER_URL+"/api/"+id+"/"+ratio,headers:{"X-Betty-Api-Key":BC_API_KEY,"Content-Type":void 0},data:selections})},this.url=function(id,crop,width,format){var exp=$interpolate("{{ url }}/{{ id }}/{{ crop }}/{{ width }}.{{ format }}");return exp({url:IMAGE_SERVER_URL,id:id,crop:crop,width:width,format:format})},this.origJpg=function(id,width){return this.url(id,"original",width,"jpg")},this.origGif=function(id,width){return this.url(id,"original",width,"gif")}}]),angular.module("bulbsCmsApp").service("IfExistsElse",["$window","$http",function(){this.ifExistsElse=function(restQ,propertiesToValues,existsCbk,elseCbk,errorCbk){restQ.then(function(data){for(var resList=data.results||data,j=0;j-1&&(formattedDate+=" "+TIMEZONE_LABEL),formattedDate}}]),angular.module("bulbsCmsApp").controller("ChangelogmodalCtrl",["$scope","$http","$modalInstance","_","ContentApi","article",function($scope,$http,$modalInstance,_,ContentApi,article){$scope.article=article,$scope.users={},ContentApi.all("log").getList({content:article.id}).then(function(data){$scope.changelog=data;var userIds=_.unique(_.pluck(data,"user"));for(var i in userIds)ContentApi.one("user",userIds[i]).get().then(function(data){$scope.users[data.id]=data})})}]),angular.module("bulbsCmsApp").controller("VersionbrowsermodalCtrl",["$scope","$window","$modalInstance","_","moment","Localstoragebackup","article",function($scope,$window,$modalInstance,_,moment,Localstoragebackup,article){Localstoragebackup.backupToLocalStorage();var keys=_.keys($window.localStorage),timestamps=[];for(var i in keys)if(!keys[i]||keys[i].split(".")[0]==Localstoragebackup.keyPrefix&&keys[i].split(".")[2]==article.id){var timestamp=1e3*Number(keys[i].split(".")[1]);timestamps.push(timestamp)}$scope.timestamps=timestamps.sort().reverse(),$scope.preview=function(timestamp,$event){$(".version-timestamp-list .active").removeClass("active"),$($event.target).parent().addClass("active");var key=Localstoragebackup.keyPrefix+"."+timestamp/1e3+"."+article.id+".body",html=$window.localStorage.getItem(key);$scope.versionPreview=html}}]),angular.module("bulbsCmsApp").service("Localstoragebackup",["$routeParams","$window","moment","$","_",function($routeParams,$window,moment,$){this.keyPrefix="articleBodyBackup",this.keySuffix="."+$routeParams.id+".body";var keyPrefix=this.keyPrefix,keySuffix=this.keySuffix;this.backupToLocalStorage=function(){var localStorageKeys=Object.keys($window.localStorage),mostRecentTimestamp=0;for(var keyIndex in localStorageKeys){var key=$window.localStorage.key(keyIndex);key&&key.split(".")[2]==$routeParams.id&&Number(key.split(".")[1])>mostRecentTimestamp&&(mostRecentTimestamp=Number(key.split(".")[1]))}var mostRecentValue=$window.localStorage.getItem(keyPrefix+"."+mostRecentTimestamp+keySuffix);if(mostRecentValue!=$("#content-body .editor").html())try{$window.localStorage&&$window.localStorage.setItem(keyPrefix+"."+moment().unix()+keySuffix,$("#content-body .editor").html())}catch(error){console.log("Caught localStorage Error "+error),console.log("Trying to prune old entries");for(var keyIndex in localStorageKeys){var key=$window.localStorage.key(keyIndex);if(!key||key.split(".")[0]==keyPrefix){var yesterday=moment().date(moment().date()-1).unix(),keyStamp=Number(key.split(".")[1]);yesterday>keyStamp&&$window.localStorage.removeItem(key)}}}}}]),angular.module("bulbsCmsApp").controller("LastmodifiedguardmodalCtrl",["$scope","$route","$modalInstance","articleOnPage","articleOnServer",function($scope,$route,$modalInstance,articleOnPage,articleOnServer){$scope.articleOnServer=articleOnServer,$scope.loadFromServer=function(){$route.reload(),$modalInstance.close()},$scope.saveAnyway=function(){$modalInstance.close(),$scope.$parent.postValidationSaveArticle()}}]); \ No newline at end of file +"use strict";angular.module("underscore",[]).value("_",window._),angular.module("NProgress",[]).value("NProgress",window.NProgress),angular.module("URLify",[]).value("URLify",window.URLify),angular.module("jquery",[]).value("$",window.$),angular.module("moment",[]).value("moment",window.moment),angular.module("bulbsCmsApp",["ngCookies","ngResource","ngSanitize","ngRoute","ui.bootstrap","ui.bootstrap.datetimepicker","restangular","BettyCropper","jquery","underscore","NProgress","URLify","moment"]).config(["$locationProvider","$routeProvider","$sceProvider","routes",function($locationProvider,$routeProvider,$sceProvider,routes){$locationProvider.html5Mode(!0),$routeProvider.when("/cms/app/list/:queue/",{templateUrl:routes.PARTIALS_URL+"contentlist.html",controller:"ContentlistCtrl",reloadOnSearch:!1}).when("/cms/app/edit/:id/",{templateUrl:routes.PARTIALS_URL+"contentedit.html",controller:"ContenteditCtrl"}).when("/cms/app/promotion/",{templateUrl:routes.PARTIALS_URL+"promotion.html",controller:"PromotionCtrl",reloadOnSearch:!1}).when("/cms/app/targeting/",{templateUrl:routes.PARTIALS_URL+"targeting-editor.html",controller:"TargetingCtrl"}).when("/cms/app/pzones/",{templateUrl:routes.PARTIALS_URL+"pzones.html",controller:"PzoneCtrl"}).otherwise({redirectTo:"/cms/app/list/published/"}),$sceProvider.enabled(!1)}]).config(["$provide",function($provide){$provide.decorator("$exceptionHandler",function($delegate){return function(exception,cause){$delegate(exception,cause),window.Raven.captureException(exception)}})}]).run(["$rootScope","$http","$cookies",function($rootScope,$http,$cookies){$http.defaults.headers.post["X-CSRFToken"]=$cookies.csrftoken;var deleteHeaders=$http.defaults.headers.delete||{};deleteHeaders["X-CSRFToken"]=$cookies.csrftoken,$http.defaults.headers.delete=deleteHeaders}]),angular.module("bulbsCmsApp").controller("ContentlistCtrl",["$scope","$http","$timeout","$location","$routeParams","$window","$q","$","_","moment","ContentApi","LOADING_IMG_SRC","routes",function($scope,$http,$timeout,$location,$routeParams,$window,$q,$,_,moment,ContentApi,LOADING_IMG_SRC,routes){function updateIsMyStuff(){if(!$location.search().authors)return void($scope.myStuff=!1);var authors=$location.search().authors;"string"==typeof authors&&(authors=[authors]),$scope.myStuff=1===authors.length&&authors[0]===$window.current_user?!0:!1}$scope.LOADING_IMG_SRC=LOADING_IMG_SRC,$window.document.title=routes.CMS_NAMESPACE+" | Content",$scope.pageNumber=$location.search().page||"1",$scope.myStuff=!1,$scope.queue=$routeParams.queue||"all",$scope.search=$location.search().search;var getContentCallback=function(data){$scope.articles=data,$scope.totalItems=data.metadata.count};$scope.getContent=function(){var params={page:$scope.pageNumber};"all"!==$scope.queue&&("published"===$scope.queue?params.before=moment().format("YYYY-MM-DDTHH:mmZ"):"waiting"===$scope.queue?params.status="Waiting for Editor":"draft"===$scope.queue?params.status="Draft":"scheduled"===$scope.queue&&(params.after=moment().format("YYYY-MM-DDTHH:mmZ")));var search=$location.search();for(var prop in search)if(search.hasOwnProperty(prop)){var val=search[prop];val&&"false"!==val&&(params[prop]=val)}ContentApi.all("content").getList(params).then(getContentCallback)},updateIsMyStuff(),$scope.getContent(),$scope.$on("$routeUpdate",function(){updateIsMyStuff()}),$scope.$watch("myStuff",function(){$scope.myStuff?$("#meOnly").bootstrapSwitch("setState",!0,!0):$("#meOnly").bootstrapSwitch("setState",!1,!0)}),$("#meOnly").on("switch-change",function(e,data){var value=data.value;value===!0?($location.search().authors=[$window.current_user],$scope.getContent()):value===!1&&(delete $location.search().authors,$scope.getContent())}),$scope.goToPage=function(page){$location.search(_.extend($location.search(),{page:page})),$scope.getContent()},$scope.sort=function(sort){$location.search().ordering&&0===$location.search().ordering.indexOf(sort)&&(sort="-"+sort),$location.search(_.extend($location.search(),{ordering:sort})),$scope.getContent()},$scope.publishSuccessCbk=function(data){var i;for(i=0;i<$scope.articles.length&&$scope.articles[i].id!==data.article.id;i++);for(var field in data.response)$scope.articles[i][field]=data.response[field];return $q.when()},$scope.trashSuccessCbk=function(){$timeout(function(){$scope.getContent(),$("#confirm-trash-modal").modal("hide")},1500)},$(".expcol").click(function(e){e.preventDefault();var nS="1"===$(this).attr("state")?"0":"1",i=nS?"minus":"plus",t=nS?"Collapse":"Expand",tP=$($(this).attr("href")).find(".panel-collapse");tP.collapse("0"===$(this).attr("state")?"show":"hide"),$(this).html(' '+t+" all"),$(this).attr("state",nS),$window.picturefill()}),$("body").on("shown.bs.collapse","table tr.panel",function(){window.picturefill()}),$("#meOnly").bootstrapSwitch()}]).directive("ngConfirmClick",[function(){return{link:function(scope,element,attr){var msg=attr.ngConfirmClick||"Are you sure?",clickAction=attr.confirmedClick;element.bind("click",function(){window.confirm(msg)&&scope.$eval(clickAction)})}}}]),angular.module("bulbsCmsApp").controller("ContenteditCtrl",["$scope","$routeParams","$http","$window","$location","$timeout","$interval","$compile","$q","$modal","$","IfExistsElse","Localstoragebackup","ContentApi","ReviewApi","Login","routes",function($scope,$routeParams,$http,$window,$location,$timeout,$interval,$compile,$q,$modal,$,IfExistsElse,Localstoragebackup,ContentApi,ReviewApi,Login,routes){function getContent(){return ContentApi.one("content",$routeParams.id).get().then(getArticleCallback)}function mediaItemExistsCbkFactory(index){return function(media_item){$scope.article.ratings[index].media_item=media_item,$scope.mediaItemCallbackCounter-=1}}function mediaItemDoesNotExistCbkFactory(index){return function(){saveMediaItem(index)}}function saveMediaItem(index){var type=$scope.article.ratings[index].type,mediaItem=$scope.article.ratings[index].media_item;mediaItem=ReviewApi.restangularizeElement(null,mediaItem,type);var q;q=mediaItem.id?mediaItem.put():mediaItem.post(),q.then(function(resp){$scope.article.ratings[index].media_item=resp,$scope.mediaItemCallbackCounter-=1}).catch(saveArticleErrorCbk)}function saveToContentApi(){$("#save-article-btn").html(" Saving"),$scope.article.put().then(saveArticleSuccessCbk,saveArticleErrorCbk)}function saveArticleErrorCbk(data){return 403===data.status?(Login.showLoginModal(),void $("#save-article-btn").html("Save")):($("#save-article-btn").html(" Error!"),400===status&&($scope.errors=data),void $scope.saveArticleDeferred.reject())}function saveArticleSuccessCbk(resp){$("#save-article-btn").html(" Saved!"),setTimeout(function(){$("#save-article-btn").html("Save")},1e3),$scope.article=resp,$scope.errors=null,$location.search("rating_type",null),dirtGone(),$scope.saveArticleDeferred.resolve(resp)}function waitForDirt(){$(".edit-page").one("change input","input,div.editor",function(){window.onbeforeunload=function(){return"You have unsaved changes. Leave anyway?"}})}function dirtGone(){window.onbeforeunload=function(){}}$scope.PARTIALS_URL=routes.PARTIALS_URL,$scope.CONTENT_PARTIALS_URL=routes.CONTENT_PARTIALS_URL,$scope.MEDIA_ITEM_PARTIALS_URL=routes.MEDIA_ITEM_PARTIALS_URL,$scope.CACHEBUSTER=routes.CACHEBUSTER;var getArticleCallback=function(data){$window.article=$scope.article=data,!$location.search().rating_type||data.ratings&&0!==data.ratings.length||($scope.article.ratings=[{type:$location.search().rating_type}]),$scope.$watch("article.detail_image.id",function(newVal,oldVal){$scope.article&&(newVal&&oldVal&&newVal===oldVal||null!==newVal&&(!$scope.article.image||!$scope.article.image.id||newVal&&oldVal&&$scope.article.image&&$scope.article.image.id&&oldVal===$scope.article.image.id||!oldVal&&newVal)&&($scope.article.image={id:newVal,alt:null,caption:null}))})};getContent(),$scope.$watch("article.title",function(){$window.document.title=routes.CMS_NAMESPACE+" | Editing "+($scope.article&&$(""+$scope.article.title+"").text())}),$("body").removeClass(),$scope.tagDisplayFn=function(o){return o.name},$scope.tagCallback=function(o,input,freeForm){var tagVal=freeForm?o:o.name;IfExistsElse.ifExistsElse(ContentApi.all("tag").getList({ordering:"name",search:tagVal}),{name:tagVal},function(tag){$scope.article.tags.push(tag)},function(value){$scope.article.tags.push({name:value.name,type:"content_tag","new":!0})},function(data,status){403===status&&Login.showLoginModal()}),$(input).val("")},$scope.sectionCallback=function(o,input,freeForm){var tagVal=freeForm?o:o.name;IfExistsElse.ifExistsElse(ContentApi.all("tag").getList({ordering:"name",search:tagVal}),{name:tagVal},function(tag){$scope.article.tags.push(tag)},function(){console.log("Can't create sections.")},function(data,status){403===status&&Login.showLoginModal()}),$(input).val("")},$scope.removeTag=function(e){var tag=$(e.target).parents("[data-tag]").data("tag"),id=tag.id,newtags=[];for(var i in $scope.article.tags)$scope.article.tags[i].id!==id&&newtags.push($scope.article.tags[i]);$scope.article.tags=newtags},$scope.removeAuthor=function(e){var author=$(e.target).parents("[data-author]").data("author"),id=author.id,newauthors=[];for(var i in $scope.article.authors)$scope.article.authors[i].id!==id&&newauthors.push($scope.article.authors[i]);$scope.article.authors=newauthors},$scope.featureTypeDisplayFn=function(o){return o.name},$scope.featureTypeCallback=function(o,input,freeForm){var fVal=freeForm?o:o.name;IfExistsElse.ifExistsElse(ContentApi.all("things").getList({type:"feature_type",q:fVal}),{name:fVal},function(ft){$scope.article.feature_type=ft.name,$("#feature-type-container").removeClass("newtag")},function(value){$scope.article.feature_type=value.name,$("#feature-type-container").addClass("newtag")},function(data,status){403===status&&Login.showLoginModal()})},$scope.authorDisplayFn=function(o){return o.first_name&&o.last_name&&o.first_name+" "+o.last_name||"username: "+o.username},$scope.authorCallback=function(o,input){for(var t in $scope.article.authors)if($scope.article.authors[t].id===o.id)return;$scope.article.authors.push(o),$(input).val("")},$scope.saveArticleDeferred=$q.defer(),$scope.mediaItemCallbackCounter=void 0,$scope.$watch("mediaItemCallbackCounter",function(){0===$scope.mediaItemCallbackCounter&&saveToContentApi()}),$scope.saveArticle=function(){return Localstoragebackup.backupToLocalStorage(),ContentApi.one("content",$routeParams.id).get().then(function(data){data.last_modified&&$scope.article.last_modified&&moment(data.last_modified)>moment($scope.article.last_modified)?($scope.saveArticleDeferred.reject(),$modal.open({templateUrl:routes.PARTIALS_URL+"modals/last-modified-guard-modal.html",controller:"LastmodifiedguardmodalCtrl",scope:$scope,resolve:{articleOnPage:function(){return $scope.article},articleOnServer:function(){return data}}})):$scope.postValidationSaveArticle()}),$scope.saveArticleDeferred.promise},$scope.postValidationSaveArticle=function(){var data=$scope.article;$scope.article.title=$scope.editors.content_title_editor.getContent(),"Published"!==$scope.article.status&&($scope.article.slug=$window.URLify($scope.article.title,50)),$scope.article.subhead=$scope.editors.content_subhead_editor.getContent(),$scope.editors.content_body_editor&&($scope.article.body=$scope.editors.content_body_editor.getContent()),$scope.mediaItemCallbackCounter=data.ratings&&data.ratings.length||saveToContentApi();for(var i in data.ratings){var show;if("tvseason"===data.ratings[i].type){var identifier=data.ratings[i].media_item.identifier;show=data.ratings[i].media_item.show,IfExistsElse.ifExistsElse(ReviewApi.all("tvseason").getList({season:identifier,show:show}),{identifier:identifier,show:show},mediaItemExistsCbkFactory(i),mediaItemDoesNotExistCbkFactory(i),saveArticleErrorCbk)}else if("tvepisode"===data.ratings[i].type){show=data.ratings[i].media_item.show;var season=data.ratings[i].media_item.season,episode=data.ratings[i].media_item.episode;IfExistsElse.ifExistsElse(ReviewApi.all("tvepisode").getList({show:show,season:season,episode:episode}),{show:show,season:season,episode:episode},mediaItemExistsCbkFactory(i),mediaItemDoesNotExistCbkFactory(i),saveArticleErrorCbk)}else saveMediaItem(i)}return $scope.saveArticleDeferred.promise},$scope.displayAuthorAutocomplete=function(obj){return obj.first_name+" "+obj.last_name},waitForDirt(),$("#extra-info-modal").on("shown.bs.modal",function(){$window.picturefill()}),$scope.initEditor=function(name,id,options,articleField){$scope.editors=$scope.editors||{},$scope.editors[name]=new window.Editor(options),angular.element(id+" .editor").bind("input",function(){$scope.article[articleField]=$scope.editors[name].getContent()})},$window.initEditor=$scope.initEditor,$scope.$on("$destroy",function(){for(var editor in $scope.editors)$scope.editors[editor].destroy()}),$scope.addRating=function(type){$scope.article.ratings.push({grade:"",type:type,media_item:{type:type}}),$("#add-review-modal").modal("hide")},$scope.deleteRating=function(index){$scope.article.ratings.splice(index,1)},$scope.publishSuccessCbk=function(){return getContent()},$scope.trashSuccessCbk=function(){$timeout(function(){$window.history.back()},1500)};!function(){var interval=6e4;return $interval(Localstoragebackup.backupToLocalStorage,interval)}()}]),angular.module("bulbsCmsApp").controller("NavCtrl",["$scope","$http","routes",function($scope,$http,routes){$scope.PARTIALS_URL=routes.PARTIALS_URL,$scope.NAV_LOGO=routes.NAV_LOGO,$http.get("/users/me").then(function(data){$scope.current_user=data.data})}]),angular.module("bulbsCmsApp").controller("PromotionCtrl",["$scope","$window","$location","$","ContentApi","PromotionApi","promo_options","routes",function($scope,$window,$location,$,ContentApi,PromotionApi,promo_options,routes){$window.document.title=routes.CMS_NAMESPACE+" | Promotion Tool",$scope.$watch("pzone",function(pzone){$scope.promotedArticles=pzone&&pzone.content&&pzone.content.length?pzone.content.slice(0):[{hey_checkthis:!0,title:"Nothing Promoted!",feature_type:"Click an article on the right and use 'Insert'"}]}),$scope.getPzones=function(){ContentApi.all("contentlist").getList().then(function(data){$scope.pzones=data,$scope.pzone=data[0]}).catch(function(){alert("Content list does not exist.")})};var getContentCallback=function(data){$scope.articles=data,$scope.totalItems=data.metadata.count};$scope.getContent=function(){var params={published:!0},search=$location.search();for(var prop in search)if(search.hasOwnProperty(prop)){var val=search[prop];val&&"false"!==val&&(params[prop]=val)}ContentApi.all("content").getList(params).then(getContentCallback)},$scope.$on("$viewContentLoaded",function(){$scope.getPzones(),$scope.getContent()}),$scope.articleIsInPromotedArticles=function(id){if($scope.promotedArticles)for(var i in $scope.promotedArticles)if($scope.promotedArticles[i].id===id)return!0;return!1};var pA=$(".promotion-area"),pC=$(".promotion-container");$scope.insertArticleMode=function(article){$scope.selectedArticle=article,pA.addClass("select-mode"),pC.off("click"),pC.on("click",".promotion-area.select-mode .article-container",function(){var index=$(this).parents("[data-index]").data("index")-0;$scope.insertArticle(index),pA.removeClass("select-mode"),$scope.$apply()})},$scope.insertArticle=function(index){var limit=promo_options.upper_limits[$scope.pzone.name];$scope.promotedArticles[index]&&$scope.promotedArticles[index].id?$scope.promotedArticles.splice(index,0,$scope.selectedArticle):$scope.promotedArticles.splice(index,1,$scope.selectedArticle),limit&&$scope.promotedArticles.length>limit&&$scope.promotedArticles.pop($scope.promotedArticles.length)},$scope.replaceArticleMode=function(article){$scope.selectedArticle=article,pA.addClass("select-mode"),pC.off("click"),pC.on("click",".promotion-area.select-mode .article-container",function(){var index=$(this).parents("[data-index]").data("index");$scope.replaceArticle(index),pA.removeClass("select-mode"),$scope.$apply()})},$scope.replaceArticle=function(index){$scope.promotedArticles.splice(index,1,$scope.selectedArticle)},$scope.save=function(){var items=$scope.promotedArticles.slice(0);items[0].id||items.shift(),$(".save-button").html(' Saving');var payload=$scope.pzone;payload.content=$scope.promotedArticles[0].hey_checkthis?[]:$scope.promotedArticles;var pzone=ContentApi.restangularizeElement(null,payload,"contentlist");return pzone.put()},$scope.moveUp=function(index){if(0!==index){var toMove=$scope.promotedArticles[index];$scope.promotedArticles[index]=$scope.promotedArticles[index-1],$scope.promotedArticles[index-1]=toMove}},$scope.moveDown=function(index){if(index!==$scope.promotedArticles.length-1){var toMove=$scope.promotedArticles[index];$scope.promotedArticles[index]=$scope.promotedArticles[index+1],$scope.promotedArticles[index+1]=toMove}},$scope.remove=function(index){$scope.promotedArticles.splice(index,1)},$("body").on("shown.bs.collapse","#page-prev .collapse",function(){$window.picturefill()})}]),angular.module("bulbsCmsApp").controller("PzoneCtrl",["$scope","$http","$window","$","ContentApi","PromotionApi","routes",function($scope,$http,$window,$,ContentApi,PromotionApi,routes){function getPzone(){PromotionApi.one("pzone/"+$scope.pzoneName).get().then(function(data){$scope.pzone=data}).catch(function(){console.log("Zone does not exist.")})}$window.document.title=routes.CMS_NAMESPACE+" | Pzone Editor",$scope.pzoneName="homepage-one",$scope.newContentId=null,$scope.$watch("pzoneName",function(){getPzone()}),$scope.typeChanged=function(){console.log("Type changed!"),void 0!==$scope.pzone&&($scope.pzone.data={})};var getContentCallback=function(data){$scope.articles=data,$scope.totalItems=data.metadata.count};$scope.getContent=function(){ContentApi.getList("content").then(getContentCallback)},$scope.getContent(),$scope.getPZoneTemplate=function(){return routes.PARTIALS_URL+"pzones/"+$scope.pzone.zone_type+".html"},$scope.remove=function(contentId){var index=$scope.pzone.data.content_ids.indexOf(contentId);-1!==index&&$scope.pzone.data.content_ids.splice(index,1)},$scope.add=function(prepend){void 0===$scope.pzone.data.content_ids&&($scope.pzone.data.content_ids=[]),prepend&&$scope.newContentIdPrepend?$scope.pzone.data.content_ids.unshift($scope.newContentIdPrepend):$scope.newContentId&&$scope.pzone.data.content_ids.push($scope.newContentId),$scope.newContentId=null,$scope.newContentIdPrepend=null},$scope.save=function(){$("#save-pzone-btn").html(' Saving');var pzone=ContentApi.restangularizeElement(null,$scope.pzone,"pzone/"+$scope.pzoneName);pzone.put().then(function(){$("#save-pzone-btn").html(' Saved!'),window.setTimeout(function(){$("#save-pzone-btn").html("Save")},2e3)}).catch(function(){$("#save-pzone-btn").html(' Saved!'),window.setTimeout(function(){$("#save-pzone-btn").html("Save")},2e3)})}}]),angular.module("bulbsCmsApp").controller("TargetingCtrl",["$scope","$http","$window","$q","$location","tar_options","NProgress","routes",function($scope,$http,$window,$q,$location,tar_options,NProgress,routes){$window.document.title=routes.CMS_NAMESPACE+" | Targeting Editor",NProgress.configure({minimum:.4});var canceller;$scope.search=function(url){url&&("undefined"==typeof canceller?canceller=$q.defer():(canceller.resolve(),NProgress.set(0),canceller=$q.defer()),NProgress.start(),$http({method:"GET",url:tar_options.endpoint,timeout:canceller.promise,params:{url:$scope.url}}).success(function(data){$scope.targetingArray=[];for(var k in data)$scope.targetingArray.push([k,data[k]]);NProgress.done()}).error(function(data,status){404==status&&($scope.targetingArray=[],$scope.targetingArray.push(["",""]),NProgress.done())}))},$scope.save=function(){var data={};for(var i in $scope.targetingArray)data[$scope.targetingArray[i][0]]=$scope.targetingArray[i][1];return $http({method:"POST",url:tar_options.endpoint+"?url="+$scope.url,data:data})},$scope.keyHandler=function(event,url){13===event.keyCode?this.search(url):27===event.keyCode&&(event.currentTarget.value="")};var search=$location.search();search&&search.url&&($scope.url=decodeURIComponent(search.url))}]),angular.module("bulbsCmsApp").controller("ContentworkflowCtrl",["$scope","$http","$modal","$window","moment","routes","TIMEZONE_LABEL",function($scope,$http,$modal,$window,moment,routes,TIMEZONE_LABEL){$scope.TIMEZONE_LABEL=TIMEZONE_LABEL,$scope.trashContentModal=function(articleId){return $modal.open({templateUrl:routes.PARTIALS_URL+"modals/confirm-trash-modal.html",controller:"TrashcontentmodalCtrl",scope:$scope,resolve:{articleId:function(){return articleId}}})},$scope.pubTimeModal=function(article){return $modal.open({templateUrl:routes.PARTIALS_URL+"modals/choose-date-modal.html",controller:"PubtimemodalCtrl",scope:$scope,resolve:{article:function(){return article}}})},$scope.sendToEditorModal=function(article){return $modal.open({templateUrl:routes.PARTIALS_URL+"modals/send-to-editor-modal.html",controller:"SendtoeditormodalCtrl",scope:$scope,resolve:{article:function(){return article}}})},$scope.changelogModal=function(article){return $modal.open({templateUrl:routes.PARTIALS_URL+"modals/changelog-modal.html",controller:"ChangelogmodalCtrl",scope:$scope,resolve:{article:function(){return article}}})},$scope.versionBrowserModal=function(article){return $modal.open({templateUrl:routes.PARTIALS_URL+"modals/version-browser-modal.html",controller:"VersionbrowsermodalCtrl",scope:$scope,size:"lg",resolve:{article:function(){return article}}})},$scope.getStatus=function(article){return article&&article.published?moment(article.published)>moment()?"scheduled":"published":"unpublished"}}]),angular.module("bulbsCmsApp").controller("TrashcontentmodalCtrl",["$scope","$http","$modalInstance","$","Login","articleId",function($scope,$http,$modalInstance,$,Login,articleId){console.log("trash content modal ctrl here"),console.log(articleId),$scope.deleteButton={idle:"Delete",busy:"Trashing",finished:"Trashed",error:"Error!"},$scope.trashContent=function(){return console.log("trash content here"),$http({method:"POST",url:"/cms/api/v1/content/"+articleId+"/trash/"})},$scope.trashCbk=function(trash_promise){trash_promise.then(function(){console.log("trash success"),$scope.trashSuccessCbk(),$modalInstance.close()}).catch(function(reason){404===reason.status?($scope.trashSuccessCbk(),$modalInstance.close()):403===status&&(Login.showLoginModal(),$modalInstance.dismiss())})}}]),angular.module("bulbsCmsApp").controller("PubtimemodalCtrl",["$scope","$http","$modal","$modalInstance","$","moment","Login","routes","article","TIMEZONE_OFFSET",function($scope,$http,$modal,$modalInstance,$,moment,Login,routes,article,TIMEZONE_OFFSET){$scope.article=article,$scope.pubButton={idle:"Publish",busy:"Publishing",finished:"Published!",error:"Error!"},$scope.$watch("pickerValue",function(newVal){var pubTimeMoment=moment(newVal).zone(TIMEZONE_OFFSET);$scope.datePickerValue=moment().year(pubTimeMoment.year()).month(pubTimeMoment.month()).date(pubTimeMoment.date()),$scope.timePickerValue=moment().hour(pubTimeMoment.hour()).minute(pubTimeMoment.minute())});var modelDateFormat="YYYY-MM-DDTHH:mmZ";$scope.setTimeShortcut=function(shortcut){if("now"==shortcut){var now=moment().zone(TIMEZONE_OFFSET);$scope.pickerValue=now}if("midnight"==shortcut){var midnight=moment().zone(TIMEZONE_OFFSET).hour(24).minute(0);$scope.pickerValue=midnight}},$scope.setDateShortcut=function(shortcut){var today=moment().zone(TIMEZONE_OFFSET);"today"==shortcut&&($scope.datePickerValue=moment().year(today.year()).month(today.month()).date(today.date())),"tomorrow"==shortcut&&($scope.datePickerValue=moment().year(today.year()).month(today.month()).date(today.date()+1))},$scope.setPubTime=function(){if(!$scope.article.feature_type)return $modalInstance.dismiss(),void $modal.open({templateUrl:routes.PARTIALS_URL+"modals/pubtime-validation-modal.html"});var newDate=moment($scope.datePickerValue),newTime=moment($scope.timePickerValue),newDateTime=moment().zone(TIMEZONE_OFFSET).year(newDate.year()).month(newDate.month()).date(newDate.date()).hour(newTime.hour()).minute(newTime.minute()).format(modelDateFormat),data={published:newDateTime};return $http({url:"/cms/api/v1/content/"+$scope.article.id+"/publish/",method:"POST",data:data})},$scope.setPubTimeCbk=function(publish_promise){publish_promise.then(function(result){$scope.article.published=result.data.published,$scope.publishSuccessCbk&&$scope.publishSuccessCbk({article:$scope.article,response:result.data}),$modalInstance.close()}).catch(function(reason){403===reason.status&&Login.showLoginModal(),$modalInstance.dismiss()})},$scope.article.published?$scope.pickerValue=moment($scope.article.published):$scope.setTimeShortcut("now")}]),angular.module("bulbsCmsApp").controller("ImageCropModalCtrl",["$scope","$timeout","$modalInstance","BettyCropper","id",function($scope,$timeout,$modalInstance,BettyCropper,id){$scope.cropMode=!1,$scope.thumb={height:180,width:180},$scope.preview_thumb={height:110,width:110},$scope.crop_image_width=550,$scope.image_url=BettyCropper.origJpg(id,$scope.crop_image_width),$scope.preview_style={};var setupCropper=function(){$("#crop-image").Jcrop({allowSelect:!1,allowMove:!0,allowResize:!0,keySupport:!1},function(){$scope.jcrop_api=this,$scope.selectedCrop=[$scope.ratioOrder[$scope.currentCrop],$scope.image.selections[$scope.ratioOrder[$scope.currentCrop]]]})};$scope.processJcropSelection=function(s){if(angular.isNumber(s.x)&&!isNaN(s.x)||angular.isNumber(s.y)&&!isNaN(s.y)||angular.isNumber(s.x2)&&!isNaN(s.x2)||angular.isNumber(s.y2)&&!isNaN(s.y2)||angular.isNumber(s.w)&&!isNaN(s.w)||angular.isNumber(s.h)&&!isNaN(s.h)){var selection={},scale=$scope.crop_image_width/$scope.image.width;selection.x0=$scope.scaleNumber(s.x,1/scale),selection.y0=$scope.scaleNumber(s.y,1/scale),selection.x1=$scope.scaleNumber(s.x2,1/scale),selection.y1=$scope.scaleNumber(s.y2,1/scale),$scope.image.selections[$scope.selectedCrop[0]]=selection,$scope.thumb_styles[$scope.selectedCrop[0]]=$scope.computeThumbStyle($scope.image,$scope.thumb,selection),$scope.preview_style=$scope.computeThumbStyle($scope.image,$scope.preview_thumb,selection)}},$scope.setSelectedCrop=function(ratio,selection){$scope.cropMode=!0,angular.isUndefined($scope.jcrop_api)?$timeout(setupCropper,0).then(function(){$scope.selectedCrop=[ratio,selection]}):$scope.selectedCrop=[ratio,selection]},$scope.$watch("selectedCrop",function(newVal){if(!angular.isUndefined(newVal)){$scope.preview_style=$scope.computeThumbStyle($scope.image,$scope.preview_thumb,newVal[1]);var scale=$scope.crop_image_width/$scope.image.width,selection=newVal[1],ratioNums=newVal[0].split("x");$scope.jcrop_api.setOptions({aspectRatio:ratioNums[0]/ratioNums[1]}),$scope.jcrop_api.setSelect([$scope.scaleNumber(selection.x0,scale),$scope.scaleNumber(selection.y0,scale),$scope.scaleNumber(selection.x1,scale),$scope.scaleNumber(selection.y1,scale)])}}),$scope.setThumbStyles=function(image,selections){$scope.thumb_styles=$scope.thumb_styles||{};for(var ratio in selections)$scope.thumb_styles[ratio]=$scope.computeThumbStyle(image,$scope.thumb,selections[ratio])},$scope.computeThumbStyle=function(image,thumb,selection){var scale,styles,h_or_w,selection_length,s_width=selection.x1-selection.x0,s_height=selection.y1-selection.y0;return s_height>s_width?(h_or_w="height",selection_length=s_height):(h_or_w="width",selection_length=s_width),styles={},scale=thumb[h_or_w]/selection_length,styles.background="url("+$scope.image_url+")",styles["background-size"]=$scope.scaleNumber($scope.image.width,scale)+"px",styles["background-position"]="-"+$scope.scaleNumber(selection.x0,scale)+"px -"+$scope.scaleNumber(selection.y0,scale)+"px",styles["background-repeat"]="no-repeat",styles.height=$scope.scaleNumber(s_height,scale)+"px",styles.width=$scope.scaleNumber(s_width,scale)+"px",styles.top="50%",styles["margin-top"]="-"+$scope.scaleNumber(s_height,scale)/2+"px",styles},$scope.scaleNumber=function(num,by_scale){return Math.floor(num*by_scale)},$scope.cancel=function(){$modalInstance.dismiss("cancel")},$scope.back=function(){$scope.cropMode=!1},$scope.saveAndQuit=function(){$scope.processJcropSelection($scope.jcrop_api.tellSelect()),BettyCropper.updateSelection($scope.image.id,$scope.selectedCrop[0],$scope.image.selections[$scope.selectedCrop[0]]).success(function(){$modalInstance.close()})},$scope.saveAndNext=function(){$scope.processJcropSelection($scope.jcrop_api.tellSelect()),BettyCropper.updateSelection($scope.image.id,$scope.selectedCrop[0],$scope.image.selections[$scope.selectedCrop[0]]).success(function(){var next=$scope.currentCrop+1;next>=$scope.ratioOrder.length&&(next=0),$scope.currentCrop=next,$scope.selectedCrop=[$scope.ratioOrder[$scope.currentCrop],$scope.image.selections[$scope.ratioOrder[$scope.currentCrop]]]})},$scope.isCurrentCrop=function(ratio){return $scope.ratioOrder[$scope.currentCrop]===ratio?{color:"#5bc0de"}:void 0},$scope.onInit=function(){BettyCropper.detail(id).success(function(data){$scope.image=data,$scope.setThumbStyles($scope.image,$scope.image.selections),$scope.ratioOrder=Object.keys($scope.image.selections),$scope.currentCrop=0})},$scope.onInit()}]),angular.module("bulbsCmsApp").controller("LoginmodalCtrl",["$scope","Login","$modalInstance","$",function($scope,Login,$modalInstance,$){$scope.login=function(){var username=$("input[name='username']").val(),password=$("input[name='password']").val();Login.login(username,password).then(function(){$modalInstance.close()},function(){$modalInstance.dismiss()})}}]),angular.module("bulbsCmsApp").controller("UnpublishCtrl",["$scope","$http","$q",function($scope,$http,$q){$scope.unpublish=function(article){var data={published:!1},deferred=$q.defer();return $http({url:"/cms/api/v1/content/"+article.id+"/publish/",method:"POST",data:data}).success(function(data){deferred.resolve({article:article,response:data})}).error(function(data){deferred.reject(data)}),deferred.promise}}]),angular.module("bulbsCmsApp").directive("activeNav",["$location",function($location){return{template:'
  • {{label}}
  • ',restrict:"E",scope:{},replace:!0,link:function(scope,element,attrs){scope.href=attrs.href,scope.label=attrs.label,0===$location.path().indexOf(scope.href)&&element.addClass("active")}}}]),angular.module("bulbsCmsApp").directive("articlecontainer",["routes","LOADING_IMG_SRC",function(routes,LOADING_IMG_SRC){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"promotion-tool-article-container.html",scope:{article:"="},link:function(scope,element,attrs){scope.LOADING_IMG_SRC=LOADING_IMG_SRC,scope.ratio=attrs.ratio}}}]),angular.module("bulbsCmsApp").directive("bulbsAutocomplete",["$http","$location","$compile","$timeout","$","Login",function($http,$location,$compile,$timeout,$,Login){return{restrict:"A",scope:!0,link:function(scope,element,attrs){function getAutocompletes(val){$timeout.cancel(inputTimeout),inputCounter=0,$http({method:"GET",url:attrs.resourceUrl+val}).success(function(data){var results=data.results||data;scope.autocomplete_list=results.splice(0,5)}).error(function(data,status){403===status&&Login.showLoginModal()})}scope.displayfn=scope[attrs.displayfn],scope.callback=scope[attrs.callback];var $elem=$(element).find("input");$elem.attr("autocomplete","off");var dropdown=$($compile($("#autocomplete-dropdown-template").html())(scope));$(dropdown).css({position:"absolute",top:$elem.position().top+$elem.outerHeight(),left:$elem.position().left,minWidth:$elem.outerWidth(),display:"none"}),$elem.parent().append(dropdown),$(dropdown).fadeIn("fast"),scope.$watch(function(){return{top:$elem.position().top+$elem.outerHeight(),left:$elem.position().left,minWidth:$elem.outerWidth()} +},function(newValue){$(dropdown).css({top:newValue.top,left:newValue.left,minWidth:newValue.minWidth})},!0);var inputTimeout,inputCounter=0;$elem.on("focus",function(){$elem.on("input",function(){var val=$elem.val();""===val?scope.autocomplete_list=[]:($timeout.cancel(inputTimeout),inputTimeout=$timeout(function(){getAutocompletes(val)},200),inputCounter>2&&getAutocompletes(val))}),$(dropdown).fadeIn("fast")}),scope.blurTimeout,$elem.on("blur",function(){$(dropdown).fadeOut("fast")}),$(dropdown).on("mouseover",".entry",function(){$(dropdown).find(".selected").removeClass("selected"),$(this).addClass("selected")}),$elem.on("keyup",function(e){if(40===e.keyCode)if(0===$("div.selected",dropdown).length)$("div.entry",dropdown).first().addClass("selected");else{var curDownSelect=$("div.selected",dropdown),curDownSelectNext=curDownSelect.next("div");0===curDownSelectNext.length?$("div.entry",dropdown).first().addClass("selected"):curDownSelectNext.addClass("selected"),curDownSelect.removeClass("selected")}if(38===e.keyCode)if(0===$("div.selected",dropdown).length)$("div.entry",dropdown).last().addClass("selected");else{var curSelect=$("div.selected",dropdown),curSelectNext=curSelect.prev("div");0===curSelectNext.length?$("div.entry",dropdown).last().addClass("selected"):curSelectNext.addClass("selected"),curSelect.removeClass("selected")}if(13===e.keyCode){var selected=$("div.selected",dropdown);0===selected.length&&scope.onClick($elem.val(),!0),selected.click()}}),scope.onClick=function(o,freeForm){scope.callback(o,$elem,freeForm||!1),scope.autocomplete_list=[]}}}}]),angular.module("bulbsCmsApp").directive("bettyeditable",["$http","routes","BettyCropper","openImageCropModal",function($http,routes,BettyCropper,openImageCropModal){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"bettyeditable.html",scope:{image:"=",addStyles:"@",placeholderText:"@",ratio:"@"},controller:["$scope","$element",function($scope){$scope.imageData=null,$scope.uploadSuccess=function(response){$scope.image||($scope.image={id:null,caption:null,alt:null}),$scope.image.id=response.id,$scope.imageData=response,$scope.showImage()},$scope.upload=function(){if(1!=this.files.length)return void console.log("We need exactly one image!");var file=this.files[0];if(0!=file.type.indexOf("image/"))return void console.log("Not an image!");file.size>68e5&&console.log("The file is too large!");var imageData=new FormData;imageData.append("image",file),BettyCropper.new(file).success($scope.uploadSuccess)}}],link:function(scope,element){var input=element.find("input");input.on("change",scope.upload);var DEFAULT_IMAGE_WIDTH=1200,ratioWidth=parseInt(scope.ratio.split("x")[0],10),ratioHeight=parseInt(scope.ratio.split("x")[1],10);element.find("#betty-editable-add-image").bind("click",function(){input[0].click()}),scope.showImage=function(){return null===scope.imageData?(console.log("Getting selections!"),void scope.getImageData()):void(scope.imageStyling=scope.computeImageStyle(scope.imageData,scope.imageData.selections[scope.ratio]))},scope.computeImageStyle=function(image,selection){var scale,styles,el_height=image.height/image.width*$(element).parent().width(),s_width=selection.x1-selection.x0,s_height=selection.y1-selection.y0,tmp_selection=selection;return s_width&&s_height||(s_width=$(element).parent().width(),s_height=el_height,tmp_selection={x0:0,y0:0,x1:s_width,y1:s_height}),styles={},scale=$(element).parent().width()/s_width,styles.background="url("+BettyCropper.origJpg(scope.image.id,DEFAULT_IMAGE_WIDTH)+")",styles["background-size"]=scope.scaleNumber(image.width,scale)+"px",styles["background-position"]="-"+scope.scaleNumber(tmp_selection.x0,scale)+"px -"+scope.scaleNumber(tmp_selection.y0,scale)+"px",styles["background-repeat"]="no-repeat",styles.height=scope.scaleNumber(s_height,scale)+"px",styles.width=scope.scaleNumber(s_width,scale)+"px",styles.position="relative",styles},scope.scaleNumber=function(num,by_scale){return Math.floor(num*by_scale)},scope.getImageData=function(){BettyCropper.detail(scope.image.id).success(function(response){scope.imageData=response,scope.showImage()}).error(function(data,status){if(404===status){var el_Height=ratioHeight/ratioWidth*$(element).parent().width();scope.imageStyling={background:"url("+BettyCropper.url(scope.image.id,scope.ratio,DEFAULT_IMAGE_WIDTH,"jpg")+")","background-size":$(element).parent().width(),height:Math.floor(el_Height)+"px",position:"relative"}}})},scope.removeImage=function(){scope.image=null},scope.editImage=function(){openImageCropModal(scope.image.id).then(function(){scope.getImageData()})},scope.image&&scope.showImage()}}}]),angular.module("bulbsCmsApp").directive("bettyimage",["$http","routes",function($http,routes){return{replace:!0,restrict:"E",templateUrl:routes.PARTIALS_URL+"bettyimage.html",scope:{image:"=",ratio:"=",width:"@"},controller:["$scope",function(){}],link:function(scope,element){scope.width=parseInt(scope.width,10);{var ratioWidth=parseInt(scope.ratio.split("x")[0],10),ratioHeight=parseInt(scope.ratio.split("x")[1],10);scope.width*ratioHeight/ratioWidth+"px"}element.css("width",scope.width+"px"),element.css("height",scope.width*ratioHeight/ratioWidth+"px");var selection=scope.image.selections[scope.ratio],selectionWidth=selection.x1-selection.x0,scale=scope.width/selectionWidth,requestWidth=Math.round(scale*(scope.image.width-selectionWidth)+scope.width);element.css("background-image","url("+routes.IMAGE_SERVER_URL+"/"+scope.image.id+"/original/"+requestWidth+".jpg)"),element.css("background-position",scale*selection.x0*-1+"px "+scale*selection.y0*-1+"px")}}}]),angular.module("bulbsCmsApp").directive("createContent",["$http","$window","$","IfExistsElse","Login","ContentApi","routes",function($http,$window,$,IfExistsElse,Login,ContentApi,routes){return{restrict:"E",templateUrl:routes.DIRECTIVE_PARTIALS_URL+"create-content.html",controller:["$scope",function($scope){function saveArticle(){$("button.go").html(' Going'),$http({url:"/cms/api/v1/content/?doctype="+$scope.contentType,method:"POST",data:$scope.init}).success(function(resp){var new_id=resp.id,new_path="/cms/app/edit/"+new_id+"/";$scope.rating_type&&(new_path+="?rating_type="+$scope.rating_type),$window.location.href=$window.location.origin+new_path}).error(function(data,status){$("button.go").html(403===status?' Please Login':' Error!'),$scope.gotSave=!1})}$scope.gotTags=!1,$scope.gotUser=!1,$scope.gotSave=!1,$scope.$watch(function(){return $scope.gotTags&&$scope.gotUser&&$scope.gotSave},function(val){val&&saveArticle($scope.init)}),$scope.newArticle=function(){var init={title:$scope.newTitle};angular.extend($scope.init,init),$scope.tag?IfExistsElse.ifExistsElse(ContentApi.all("tag").getList({ordering:"name",search:$scope.tag}),{slug:$scope.tag},function(tag){$scope.init.tags=[tag],$scope.gotTags=!0},function(value){console.log("couldnt find tag "+value.slug+" for initial value")},function(data,status){403===status&&Login.showLoginModal()}):$scope.gotTags=!0,$http.get("/users/me/").then(function(data){$scope.init.authors=[data.data],$scope.gotUser=!0}),$scope.gotSave=!0}}],link:function(scope,element){$(element).find("a.create-content").on("click",function(){$("a.create-content.active").removeClass("active"),$(this).addClass("active")}),$(element).find("a.create-content").on("click",function(){return scope.contentTypeLabel=$(this).text(),scope.contentType=$(this).data("content_type")||null,scope.init=$(this).data("init")||{},scope.tag=$(this).data("tag")||null,scope.rating_type=$(this).data("rating_type")||null,scope.$apply(),$(this).hasClass("go-next")&&$("#create button.next-pane").click(),!0}),$("button.next-pane:not(.hide)").on("click",function(){console.log("next clicked"),console.log(scope.contentType),console.log(scope.init),$("#createcontent-01").addClass("hidden"),$("#createcontent-02").removeClass("hidden"),$("button.next-pane:not(.hide)").addClass("hidden"),$(".new-title").focus()}),$(element).find(".new-title").on("keydown",function(e){13===e.keyCode&&$(element).find(".go").click()})}}}]),angular.module("bulbsCmsApp").directive("devicepreview",["$","routes",function($,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"devicepreview.html",link:function(){var pP=$("#page-prev"),tN=pP.find(".nav a"),cO=pP.find(".tab-content .active");tN.click(function(e){var newId=$(this).attr("href").split("#")[1];e.preventDefault(),cO.attr("id",newId)}),$("#page-prev").on("show.bs.collapse",function(){$(this).find(".fa").removeClass("fa-plus-square-o").addClass("fa-minus-square-o")}),$("#page-prev").on("hide.bs.collapse",function(){$(this).find(".fa").removeClass("fa-minus-square-o").addClass("fa-plus-square-o")})}}}]),angular.module("bulbsCmsApp").directive("filterwidget",["$http","$location","$window","$timeout","$","routes",function($http,$location,$window,$timeout,$,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"filterwidget.html",link:function(scope,element){function getAutocompletes(search){return $timeout.cancel(filterInputTimeout),filterInputCounter=0,search.length<1?(scope.autocompleteArray=[],void scope.$apply()):void $http({url:"/cms/api/v1/things/?type=tag&type=feature_type&type=author",method:"GET",params:{q:search}}).success(function(data){scope.autocompleteArray=data})}function arrowSelect(direction){var $toSelect,$entries=$element.find(".entry"),$selected=$element.find(".entry.selected");$selected.length>0?("up"===direction&&($toSelect=$selected.first().prev()),"down"===direction&&($toSelect=$selected.first().next())):("up"===direction&&($toSelect=$entries.last()),"down"===direction&&($toSelect=$entries.first())),scope.selectEntry($toSelect)}function applyFilterChange(filterObject){filterObject.page=1,$location.search(filterObject),scope.getContent(),scope.autocompleteArray=[],$input.trigger("blur")}function getFilterObjects(){var search=$location.search();if(scope.filterObjects={},"undefined"==typeof search)return void console.log("udnefined");var filterParamsToTypes={authors:"author",tags:"tag",feature_types:"feature_type"};for(var filterParam in filterParamsToTypes){var filterType=filterParamsToTypes[filterParam];"string"==typeof search[filterParam]&&(search[filterParam]=[search[filterParam]]);for(var i in search[filterParam]){var value=search[filterParam][i];scope.filterObjects[filterType+value]={query:value,type:filterParam},getQueryToLabelMappings(filterType,value)}}search.search&&(scope.filterInputValue=search.search)}function getQueryToLabelMappings(type,query){scope.queryToLabelMappings=scope.queryToLabelMappings||{},query in scope.queryToLabelMappings||$http({url:"/cms/api/v1/things/?type="+type,method:"GET",params:{q:query}}).success(function(data){for(var i in data)scope.queryToLabelMappings[data[i].value]=data[i].name})}var $element=$(element),$input=$element.find("input");scope.searchTerm,scope.autocompleteArray=[];var filterInputTimeout,filterInputCounter=0;$input.on("input",function(){var search=$input.val();scope.searchTerm=search,$timeout.cancel(filterInputTimeout),filterInputTimeout=$timeout(function(){getAutocompletes(search)},200),filterInputCounter>2&&getAutocompletes(search)}),$input.on("keyup",function(e){38===e.keyCode&&arrowSelect("up"),40===e.keyCode&&arrowSelect("down"),13===e.keyCode&&($element.find(".selected").length>0?$element.find(".selected").click():scope.addFilter("search",$input.val()))}),$element.find(".search-button").on("click",function(){scope.addFilter("search",$input.val())}),$element.find(".clear-button").on("click",function(){$(this).prev("input").val(""),scope.filterObjects={},applyFilterChange({})}),$element.on("mouseover",".entry",function(){scope.selectEntry(this)}),scope.selectEntry=function(entry){$element.find(".selected").removeClass("selected"),$(entry).addClass("selected")},$input.on("blur",function(){$element.find(".dropdown-menu").fadeOut(200)}),$input.on("focus",function(){$element.find(".dropdown-menu").fadeIn(200)}),scope.addFilter=function(type,newFilterValue){var filterObject=$location.search();"search"===type?filterObject.search=newFilterValue:(filterObject[type]||(filterObject[type]=[]),"string"==typeof filterObject[type]&&(filterObject[type]=[filterObject[type]]),filterObject[type].push(newFilterValue),$input.val("")),applyFilterChange(filterObject),scope.filterInputValue=""},scope.deleteFilter=function(key){var filterObject=$location.search(),toDelete=scope.filterObjects[key];"string"==typeof filterObject[toDelete.type]&&(filterObject[type]=[filterObject[type]]);var toSplice;for(var i in filterObject[toDelete.type])if(filterObject[toDelete.type][i]===toDelete.query){toSplice=i;break}filterObject[toDelete.type].splice(i,1),filterObject.search=$input.val(),delete scope.filterObjects[key],applyFilterChange(filterObject)},scope.$on("$routeUpdate",function(){getFilterObjects()}),getFilterObjects()}}}]),angular.module("bulbsCmsApp").directive("imagedrawer",["$http","$window","$","routes","BC_API_KEY",function($http,$window,$,routes,BC_API_KEY){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"imagedrawer.html",scope:{openImageDrawer:"=",closeImageDrawer:"=",article:"="},controller:["$scope",function($scope){function scaleSelection(scale,selection){return[Math.floor(scale*selection[0]),Math.floor(scale*selection[1]),Math.floor(scale*selection[2]),Math.floor(scale*selection[3])]}$scope.current_image={},$scope.$watch("current_image",function(){$scope.library_images=prependCurrentImage($scope.library_images,$scope.current_image)}),$scope.library_images=[];var prependCurrentImage=function(library,current_image){var new_library=library;if(current_image.id){for(var i in new_library)if(new_library[i].id===current_image.id){new_library.splice(i,1);break}new_library.unshift(current_image)}return new_library},refreshImageLibrary=function(params){params=params||{},$http({method:"GET",url:routes.BC_ADMIN_URL+"/api/search",params:params,headers:{"X-Betty-Api-Key":BC_API_KEY}}).success(function(data){$scope.library_images=prependCurrentImage(data.results,$scope.current_image)})};$scope.drawerUpload=function(){$window.uploadImage({onProgress:function(){},onSuccess:function(data){refreshImageLibrary(),$scope.onChangeFn(data),$scope.current_image=data},onError:$scope.onCancelFn,onCancel:$scope.onCancelFn})};var refreshCurrentImage=function(id,field){$http({url:routes.BC_ADMIN_URL+"/api/"+id,method:"GET",headers:{"X-Betty-Api-Key":BC_API_KEY}}).success(function(data){field?$scope.current_image[field]=data[field]:$scope.current_image=data,$window.picturefill(!0)}).error(function(){$scope.current_image={}})};$window.refreshCurrentImage=refreshCurrentImage,$scope.$watch("imageLibrarySearch",function(){refreshImageLibrary({q:$scope.imageLibrarySearch})}),$scope.openImageDrawer=function(){var oldId,onChangeFn,onSaveFn,onCancelFn;"function"==typeof arguments[0]?(oldId=null,onChangeFn=arguments[0],onSaveFn=arguments[1],onCancelFn=arguments[2]):(oldId=arguments[0],onChangeFn=arguments[1],onSaveFn=arguments[2],onCancelFn=arguments[3]),$("#image-drawer").off("click"),$("#image-drawer").on("click","#image-library.image",function(){var id=$(this).data("imageId");refreshCurrentImage(id),onChangeFn(id)}),oldId&&($scope.original_image=oldId),refreshCurrentImage(oldId),$scope.oldId=oldId,$scope.onChangeFn=onChangeFn,$scope.onSaveFn=onSaveFn,$scope.onCancelFn=function(id){$scope.original_image&&refreshCurrentImage($scope.original_image),onCancelFn(id)},$("body").addClass("image-drawer-cropper-open"),refreshImageLibrary()},$window.openImageDrawer=$scope.openImageDrawer,$scope.openImageLibrary=function(){$scope.libraryOpen=!0,$("body").addClass("image-drawer-library-open"),$window.picturefill(!0)},$scope.closeImageDrawer=function(){$("body").removeClass("image-drawer-cropper-open"),$("body").removeClass("image-drawer-library-open"),$window.picturefill()},$scope.closeImageLibrary=function(action){"save"===action&&$scope.onSaveFn(),"cancel"===action&&$scope.onCancelFn($scope.oldId),$("body").removeClass("image-drawer-library-open"),$scope.libraryOpen=!1},$scope.saveImageData=function(e){$window.saveImageData(e)},$scope.saveNewCrop=function(image,ratio){image.selections[ratio]={x0:user_selection_scaled[0],y0:user_selection_scaled[1],x1:user_selection_scaled[2],y1:user_selection_scaled[3]},$scope.$apply(),$window.saveNewCrop(image,ratio,user_selection_scaled,{onSuccess:function(){refreshCurrentImage(image.id,"selections")}})};var jcrop_api,user_selection,user_selection_scaled;$("#cropperModal").on("hidden.bs.modal",function(){jcrop_api.destroy()}),$("#cropperModal").on("shown.bs.modal",function(){$window.picturefill()}),$scope.cropImage=function(image,ratio){var width=500;$("#cropper-img").attr("src",routes.IMAGE_SERVER_URL+"/"+image.id+"/original/"+width+".jpg");var aspectWidth=ratio.split("x")[0],aspectHeight=ratio.split("x")[1],scale=width/image.width,selection=[image.selections[ratio].x0,image.selections[ratio].y0,image.selections[ratio].x1,image.selections[ratio].y1],onSelect=function(c){var selection=[c.x,c.y,c.x2,c.y2];user_selection=selection,user_selection_scaled=scaleSelection(1/scale,selection)};$("#cropper-modal-save-button").unbind("click"),$("#cropper-modal-save-button").click(function(){$scope.saveNewCrop(image,ratio)}),$("#cropperModal").modal("show"),$("#cropper-img").Jcrop({onSelect:onSelect,allowMove:!0,allowResize:!0,aspectRatio:aspectWidth/aspectHeight},function(){jcrop_api=this,jcrop_api.setOptions({aspectRatio:aspectWidth/aspectHeight}),this.focus();scaleSelection(scale,selection);this.setSelect(scaleSelection(scale,selection))})}}],link:function(scope){function preventDefault(e){e=e||window.event,e.preventDefault&&e.preventDefault(),e.returnValue=!1}scope.IMAGE_SERVER_URL=routes.IMAGE_SERVER_URL,document.getElementById("image-cropper").onmousewheel=function(e){document.getElementById("image-cropper").scrollTop-=e.wheelDeltaY,preventDefault(e)},document.getElementById("image-library-body").onmousewheel=function(e){document.getElementById("image-library-body").scrollTop-=e.wheelDeltaY,preventDefault(e)}}}}]),angular.module("bulbsCmsApp").directive("listinput",["$","routes",function($,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"listinput.html",scope:{model:"="},link:function(scope,element,attrs){scope.label=attrs.label,scope.noun=attrs.noun,element.find("input")[0].setAttribute("name",attrs.noun),element.find("input").bind("focus",function(){$(element).find(".preview").hide(),$(element).find(".all-container").show()}),element.find("input").bind("blur",function(){$(element).find(".all-container").hide(),$(element).find(".preview").show()}),element.find("input").bind("keyup",function(e){if(13===e.keyCode){var value=$(this).val();value.length>0&&(scope.model||(scope.model=[]),scope.model.push($(this).val()),scope.$apply(),$(this).val(""))}})}}}]),angular.module("bulbsCmsApp").directive("videoUpload",["$http","$window","$timeout","$sce","$","routes",function($http,$window,$timeout,$sce,$,routes){return{templateUrl:routes.PARTIALS_URL+"mainvideo.html",scope:{article:"="},restrict:"E",link:function(scope,element){function abortUpload(){setProgress(0),scope.req&&scope.req.abort(),scope.video={},setProgress(0)}function abortEncode(){$.ajax("https://app.zencoder.com/api/v2/jobs/"+scope.video.job_id+"/cancel.json?api_key="+$window.videoAttrs.zencoderApiKey,{type:"PUT",success:function(){scope.video.status=3,fakeInput.val("Encoding failed! Please try again.")}})}function setProgress(progress){return 0===progress||100===progress?void progressEl.hide():void((0===scope.lastProgress||Math.abs(progress-scope.lastProgress)>2)&&(progressBar.css("width",Math.floor(progress)+"%"),scope.lastProgress=progress,progressEl.show()))}function updateEncodeProgress(){progressBar.addClass("progress-bar-success"),delete $http.defaults.headers.common["X-Requested-With"],$http({url:"https://app.zencoder.com/api/v2/jobs/"+scope.video.job_id+"/progress.json",method:"GET",params:{api_key:$window.videoAttrs.zencoderApiKey},useXDomain:!0}).success(function(data){"waiting"===data.state||"pending"===data.state||"processing"===data.state?(scope.video.status=2,data.progress>5?(setProgress(data.progress),$timeout(updateEncodeProgress,500)):$timeout(updateEncodeProgress,2e3)):(setProgress(0),"finished"===data.state&&(scope.video.status=1),("failed"===data.state||"cancelled"===data.state)&&(scope.video.status=3,fakeInput.val("Encoding failed! Please try again.")))}).error(function(){$(".alert-danger").fadeIn().delay(1e3).fadeOut()})}console.log("video upload here"),console.log(scope.video_id),scope.$watch("article.video",function(){scope.article.video&&(scope.embedUrl=$sce.trustAsUrl("/videos/embed?id="+scope.article.video),$http({method:"GET",url:"/videos/api/video/"+scope.article.video+"/"}).success(function(data){console.log("getting video from API"),console.log(data),scope.video=data,$window.initVideoWidget(data.id)}))}),scope.$watch("video",function(){});var progressEl=(element.find("label.btn"),element.find("div.progress")),progressBar=element.find("div.progress-bar"),fakeInput=(element.find("div.progress span"),element.find("input.fake-input"));scope.lastProgress=0,scope.addVideo=function(){console.log("chooseFile"),$window.uploadVideo(element.find(".video-container")[0],{onSuccess:function(videoid){scope.$apply(function(){console.log("addVideo onSuccess callback"),console.log(videoid),scope.article.video=videoid})},onError:function(data){console.log("addVideo onError callback"),console.log(data)},onProgress:function(data){console.log("addVideo onProgress callback"),console.log(data)}})},scope.clearVideo=function(areYouSure){areYouSure?($("#s3upload-file-input").val(""),scope.article.video=null):$("#confirm-clear-video-modal").modal("show")},scope.abort=function(){return scope.encoding?void abortEncode():void abortUpload()};var initialCheckRan=!1;scope.$watch("video",function(){scope.video&&scope.video.job_id&&!initialCheckRan&&(updateEncodeProgress(),initialCheckRan=!0)})}}}]),angular.module("bulbsCmsApp").directive("mediaRating",["$http","$","routes",function($http,$,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"rating.html",scope:!0,controller:["$scope",function($scope){$scope.search=function(el){$scope.searchTimeout=null;for(var inputs=el.find(".media-field input"),searchParams={},i=0;i "+scope.config.busy);var save_promise=scope.getPromise(),promise=save_promise.then(function(result){return NProgress.done(),element.prop("disabled",!1).removeClass("btn-danger").html(" "+scope.config.finished),$timeout(function(){element.html(scope.config.idle)},1e3),result},function(reason){return NProgress.done(),element.prop("disabled",!1).addClass("btn-danger").html(" "+scope.config.error),$q.reject(reason)});scope.saveCbk&&scope.saveCbk({promise:promise})}}}}]),angular.module("bulbsCmsApp").directive("slideshowPane",["$http","$window","$compile","$","routes",function($http,$window,$compile,$,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"slideshow-pane.html",scope:{article:"=",image:"=",index:"="},link:function(scope,element,attrs){var $element=$(element);"false"===attrs.caption&&(scope.hideCaption=!0),scope.format=attrs.format||"jpg",scope.crop=attrs.crop||"16x9",scope.removeImage=function(index){scope.article.slides.splice(index,1)},scope.editImage=function(index){$window.openImageDrawer(scope.article.slides[index].id,function(data){function removeLoadingGif(){$element.find('.image img[src="'+routes.LOADING_IMG_SRC+'"]').remove()}removeLoadingGif(),$element.find(".image").data("imageId")!==data.id&&($element.find(".image img").on("load",removeLoadingGif),$element.find(".image img").after(''),scope.article.slides[index].id=data.id.toString(),scope.$apply(),$window.picturefill(),$element.find(".image img")[0].complete&&removeLoadingGif())},function(){},function(oldImage){scope.article.slides[index]=oldImage,$window.picturefill()})}}}}]),angular.module("bulbsCmsApp").directive("targeting",["routes",function(routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"targeting.html",link:function(scope){scope.addTargetingRow=function(){scope.targetingArray.push([])},scope.removeTargetingRow=function(index){scope.targetingArray.splice(index,1)}}}}]),angular.module("bulbsCmsApp").directive("titleimage",["$http","$window","$","routes",function($http,$window,$,routes){return{restrict:"E",templateUrl:routes.PARTIALS_URL+"titleimage.html",scope:{article:"=",image:"="},link:function(scope,element,attrs){var $element=$(element);"false"===attrs.caption&&(scope.hideCaption=!0),scope.format=attrs.format||"jpg",scope.crop=attrs.crop||"16x9",scope.placeholderText=attrs.placeholderText||"Optional Image",scope.removeTitleImage=function(){scope.image=null},scope.addTitleImage=function(){$window.uploadImage({onSuccess:function(data){scope.$apply(function(){scope.image={id:data.id.toString(),alt:null,caption:null},setTimeout($window.picturefill,200)})},onError:function(data){scope.$apply(function(){alert("Error: ",data)})},onProgress:function(){}})},scope.editTitleImage=function(){$window.openImageDrawer(scope.image.id,function(data){function removeLoadingGif(){$element.find('.image img[src="'+routes.LOADING_IMG_SRC+'"]').remove()}removeLoadingGif(),$element.find(".image").data("imageId")!==data.id&&($element.find(".image img").on("load",removeLoadingGif),$element.find(".image img").after(''),scope.image.id=data.id.toString(),scope.$apply(),$window.picturefill(),$element.find(".image img")[0].complete&&removeLoadingGif())},function(){},function(oldImage){scope.image=oldImage,$window.picturefill()})}}}}]),angular.module("bulbsCmsApp").filter("truncateByCharacters",function(){return function(input,chars,breakOnWord){if(isNaN(chars))return input;if(0>=chars)return"";if(input&&input.length>=chars){if(input=input.substring(0,chars),breakOnWord)for(;" "===input.charAt(input.length-1);)input=input.substr(0,input.length-1);else{var lastspace=input.lastIndexOf(" ");-1!==lastspace&&(input=input.substr(0,lastspace))}return 1===chars?input+".":input+"..."}return input}}),angular.module("bulbsCmsApp").filter("truncateByWords",function(){return function(input,words){if(isNaN(words))return input;if(0>=words)return"";if(input){var inputWords=input.split(/\s+/);inputWords.length>words&&(input=inputWords.slice(0,words).join(" ")+"...")}return input}}),function(global){var OnionCmsUI=OnionCmsUI||function(editor){function init(){toolbarPosition=$("#content-body .document-tools").offset().top+12,$(window).scroll(function(){window.scrollY>toolbarPosition?$("#content-body .document-tools").addClass("fixed"):$("#content-body .document-tools").removeClass("fixed")}),key("⌘+s, ctrl+s",function(e){e.preventDefault()})}var toolbarPosition;editor.on("init",init)};global.EditorModules.push(OnionCmsUI)}(this),function(global){var OnionImage=OnionImage||function(editor){function uploadImage(options){function onProgress(){}function onSuccess(data){options.onSuccess(options.block,{image_id:data.id}),window.picturefill()}function onError(){}function onCancel(){}global.uploadImage({onProgress:onProgress,onSuccess:onSuccess,onError:onError,onCancel:onCancel})}function editImage(options){function onDrawerImageChange(id){$(options.element).attr("data-image-id",id),window.picturefill()}function onDrawerSave(){}function onDrawerCancel(){}current_id=options.element.getAttribute("data-image-id"),openImageDrawer(current_id,onDrawerImageChange,onDrawerSave,onDrawerCancel)}editor.on("inline:edit:image",editImage),editor.on("inline:insert:image",uploadImage);var current_id};global.EditorModules.push(OnionImage)}(this),function(global){var OnionVideo=OnionVideo||function(editor){function cleanup(){for(var old_embeds=$("[data-type=embed] iframe[src^='/videos/embed']").parents("div.embed"),i=0;i")}editor.on("inline:insert:hr",insert)};global.EditorModules.push(HR)}(this),$(document).unbind("keydown").bind("keydown",function(event){var doPrevent=!1;if(8===event.keyCode){var d=event.srcElement||event.target;doPrevent=["TEXTAREA","INPUT"].indexOf(-1!==d.tagName.toUpperCase())?d.readOnly||d.disabled:d.isContentEditable?!1:!0}doPrevent&&event.preventDefault()}),angular.module("BettyCropper",[]).service("BettyCropper",["$http","$interpolate","IMAGE_SERVER_URL","BC_API_KEY",function($http,$interpolate,IMAGE_SERVER_URL,BC_API_KEY){this.detail=function(id){return $http({method:"GET",url:IMAGE_SERVER_URL+"/api/"+id,headers:{"X-Betty-Api-Key":BC_API_KEY,"Content-Type":void 0},transformRequest:angular.identity})},this.detailPatch=function(id,name,credit,selections){return $http({method:"PATCH",url:IMAGE_SERVER_URL+"/api/"+id,headers:{"X-Betty-Api-Key":BC_API_KEY,"Content-Type":void 0},data:{name:name,credit:credit,selections:selections},transformRequest:angular.identity})},this.new=function(image,name,credit){var imageData=new FormData;return imageData.append("image",image),name&&imageData.append("name",name),credit&&imageData.append("credit",credit),$http({method:"POST",url:IMAGE_SERVER_URL+"/api/new",headers:{"X-Betty-Api-Key":BC_API_KEY,"Content-Type":void 0},data:imageData,transformRequest:angular.identity})},this.updateSelection=function(id,ratio,selections){return $http({method:"POST",url:IMAGE_SERVER_URL+"/api/"+id+"/"+ratio,headers:{"X-Betty-Api-Key":BC_API_KEY,"Content-Type":void 0},data:selections})},this.url=function(id,crop,width,format){var exp=$interpolate("{{ url }}/{{ id }}/{{ crop }}/{{ width }}.{{ format }}");return exp({url:IMAGE_SERVER_URL,id:id,crop:crop,width:width,format:format})},this.origJpg=function(id,width){return this.url(id,"original",width,"jpg")},this.origGif=function(id,width){return this.url(id,"original",width,"gif")}}]),angular.module("bulbsCmsApp").service("IfExistsElse",["$window","$http",function(){this.ifExistsElse=function(restQ,propertiesToValues,existsCbk,elseCbk,errorCbk){restQ.then(function(data){for(var resList=data.results||data,j=0;j-1&&(formattedDate+=" "+TIMEZONE_LABEL),formattedDate}}]),angular.module("bulbsCmsApp").controller("ChangelogmodalCtrl",["$scope","$http","$modalInstance","_","ContentApi","article",function($scope,$http,$modalInstance,_,ContentApi,article){$scope.article=article,$scope.users={},ContentApi.all("log").getList({content:article.id}).then(function(data){$scope.changelog=data;var userIds=_.unique(_.pluck(data,"user"));for(var i in userIds)ContentApi.one("author",userIds[i]).get().then(function(data){$scope.users[data.id]=data})})}]),angular.module("bulbsCmsApp").controller("VersionbrowsermodalCtrl",["$scope","$window","$modalInstance","_","moment","Localstoragebackup","article",function($scope,$window,$modalInstance,_,moment,Localstoragebackup,article){Localstoragebackup.backupToLocalStorage();var keys=_.keys($window.localStorage),timestamps=[];for(var i in keys)if(!keys[i]||keys[i].split(".")[0]==Localstoragebackup.keyPrefix&&keys[i].split(".")[2]==article.id){var timestamp=1e3*Number(keys[i].split(".")[1]);timestamps.push(timestamp)}$scope.timestamps=timestamps.sort().reverse(),$scope.preview=function(timestamp,$event){$(".version-timestamp-list .active").removeClass("active"),$($event.target).parent().addClass("active");var key=Localstoragebackup.keyPrefix+"."+timestamp/1e3+"."+article.id+".body",html=$window.localStorage.getItem(key);$scope.versionPreview=html}}]),angular.module("bulbsCmsApp").service("Localstoragebackup",["$routeParams","$window","moment","$","_",function($routeParams,$window,moment,$){this.keyPrefix="articleBodyBackup",this.keySuffix="."+$routeParams.id+".body";var keyPrefix=this.keyPrefix,keySuffix=this.keySuffix;this.backupToLocalStorage=function(){var localStorageKeys=Object.keys($window.localStorage),mostRecentTimestamp=0;for(var keyIndex in localStorageKeys){var key=$window.localStorage.key(keyIndex);key&&key.split(".")[2]==$routeParams.id&&Number(key.split(".")[1])>mostRecentTimestamp&&(mostRecentTimestamp=Number(key.split(".")[1]))}var mostRecentValue=$window.localStorage.getItem(keyPrefix+"."+mostRecentTimestamp+keySuffix);if(mostRecentValue!=$("#content-body .editor").html())try{$window.localStorage&&$window.localStorage.setItem(keyPrefix+"."+moment().unix()+keySuffix,$("#content-body .editor").html())}catch(error){console.log("Caught localStorage Error "+error),console.log("Trying to prune old entries");for(var keyIndex in localStorageKeys){var key=$window.localStorage.key(keyIndex);if(!key||key.split(".")[0]==keyPrefix){var yesterday=moment().date(moment().date()-1).unix(),keyStamp=Number(key.split(".")[1]);yesterday>keyStamp&&$window.localStorage.removeItem(key)}}}}}]),angular.module("bulbsCmsApp").controller("LastmodifiedguardmodalCtrl",["$scope","$route","$modalInstance","ContentApi","articleOnPage","articleOnServer",function($scope,$route,$modalInstance,ContentApi,articleOnPage,articleOnServer){$scope.articleOnServer=articleOnServer,ContentApi.all("log").getList({content:article.id}).then(function(log){var latest=_.max(log,function(entry){return moment(entry.action_time)}),lastSavedById=latest.user;ContentApi.one("author",lastSavedById).get().then(function(data){$scope.lastSavedBy=data})}),$scope.loadFromServer=function(){$route.reload(),$modalInstance.close()},$scope.saveAnyway=function(){$modalInstance.close(),$scope.$parent.postValidationSaveArticle()}}]),angular.module("bulbsCmsApp").filter("user",function(){return function(user){return user?user.first_name&&user.last_name?user.first_name+" "+user.last_name:user.username:""}}); \ No newline at end of file diff --git a/dist/scripts/templates.js b/dist/scripts/templates.js index 34bca8f36..9d8590d5d 100644 --- a/dist/scripts/templates.js +++ b/dist/scripts/templates.js @@ -1,2 +1,2 @@ -angular.module("bulbsCmsApp").run(["$templateCache",function($templateCache){"use strict";$templateCache.put("/views/bettyeditable.html",'
    '),$templateCache.put("/views/bettyimage.html","
    "),$templateCache.put("/views/contentedit.html",'
    {{field}}
    {{error}}

    Error: article has no content type.

    '),$templateCache.put("/views/contentlist.html",'
    {{ article.feature_type }}
    By {{ article.authors.0.first_name | truncateByCharacters: 1 }} {{ article.authors.0.last_name }} and {{ article.authors.length - 1}} others · {{ article.published|tzDate:"EEE\',\' M/d/yy\' at \' h:mm a" }} Draft Scheduled for {{ article.published|tzDate:"EEE M/d/yy \'at\' h:mm a" }}
    Status
    {{ article.published|tzDate:"EEE\',\' M/d/yy\' at \' h:mm a" }} Draft Scheduled for {{ article.published|tzDate:"EEE M/d/yy \'at\' h:mm a" }}
    Authors
    {{ author.first_name }} {{ author.last_name }},
    Feature type
    {{ article.feature_type }}
    Tags
    {{ tag.name | truncateByWords:3 }},
    Article ID
    {{ article.id }}
    '),$templateCache.put("/views/create-content.html",'"),$templateCache.put("/views/devicepreview.html",'
    No image selected.
    '),$templateCache.put("/views/filterwidget.html",'
    {{queryToLabelMappings[f.query]}}
    Clear filters
    "),$templateCache.put("/views/image-crop-modal.html",'
    '),$templateCache.put("/views/imagedrawer.html",'
    Images
    No image, no selections
    {{ratio}}
    '),$templateCache.put("/views/listinput.html",'
    {{model[0]}} ...
    {{m}}
    '),$templateCache.put("/views/mainvideo.html",'
    '),$templateCache.put("/views/modals/changelog-modal.html",''),$templateCache.put("/views/modals/choose-date-modal.html",''),$templateCache.put("/views/modals/confirm-trash-modal.html",''),$templateCache.put("/views/modals/last-modified-guard-modal.html",''),$templateCache.put("/views/modals/login-modal.html",''),$templateCache.put("/views/modals/pubtime-validation-modal.html",''),$templateCache.put("/views/modals/send-to-editor-modal.html",''),$templateCache.put("/views/modals/version-browser-modal.html",''),$templateCache.put("/views/nav.html",''),$templateCache.put("/views/promotion-tool-article-container.html",'
    No image selected.

    ·

    '),$templateCache.put("/views/promotion.html",'

    Currently promoted

    '),$templateCache.put("/views/pzones.html",'

    Promotion Zone Editor

    '),$templateCache.put("/views/pzones/carousel.html","
    Looks like this P'Zone is outdated
    "),$templateCache.put("/views/pzones/feature_type.html","
    Coming soon!
    "),$templateCache.put("/views/pzones/list.html",'
    Content IDActions
    '),$templateCache.put("/views/pzones/oneup.html","
    Looks like this P'Zone is outdated
    "),$templateCache.put("/views/pzones/reviews.html",'

    The "reviews" promoted zone has no available options.

    '),$templateCache.put("/views/pzones/twoup.html","
    Looks like this P'Zone is outdated
    "),$templateCache.put("/views/rating.html",'
    '),$templateCache.put("/views/save-button.html",""),$templateCache.put("/views/targeting-editor.html",'

    Targeting Editor

    '),$templateCache.put("/views/targeting.html",'
    KeyValue
    '),$templateCache.put("/views/titleimage.html",'
    '),$templateCache.put("/views/toolbar.html",'') +angular.module("bulbsCmsApp").run(["$templateCache",function($templateCache){"use strict";$templateCache.put("/views/bettyeditable.html",'
    '),$templateCache.put("/views/bettyimage.html","
    "),$templateCache.put("/views/contentedit.html",'
    {{field}}
    {{error}}

    Error: article has no content type.

    '),$templateCache.put("/views/contentlist.html",'
    {{ article.feature_type }}
    By {{ article.authors.0.first_name | truncateByCharacters: 1 }} {{ article.authors.0.last_name }} and {{ article.authors.length - 1}} others · {{ article.published|tzDate:"EEE\',\' M/d/yy\' at \' h:mm a" }} Draft Scheduled for {{ article.published|tzDate:"EEE M/d/yy \'at\' h:mm a" }}
    Status
    {{ article.published|tzDate:"EEE\',\' M/d/yy\' at \' h:mm a" }} Draft Scheduled for {{ article.published|tzDate:"EEE M/d/yy \'at\' h:mm a" }}
    Authors
    {{ author.first_name }} {{ author.last_name }},
    Feature type
    {{ article.feature_type }}
    Tags
    {{ tag.name | truncateByWords:3 }},
    Article ID
    {{ article.id }}
    '),$templateCache.put("/views/create-content.html",'"),$templateCache.put("/views/devicepreview.html",'
    No image selected.
    '),$templateCache.put("/views/filterwidget.html",'
    {{queryToLabelMappings[f.query]}}
    Clear filters
    "),$templateCache.put("/views/image-crop-modal.html",'
    '),$templateCache.put("/views/imagedrawer.html",'
    Images
    No image, no selections
    {{ratio}}
    '),$templateCache.put("/views/listinput.html",'
    {{model[0]}} ...
    {{m}}
    '),$templateCache.put("/views/mainvideo.html",'
    '),$templateCache.put("/views/modals/changelog-modal.html",''),$templateCache.put("/views/modals/choose-date-modal.html",''),$templateCache.put("/views/modals/confirm-trash-modal.html",''),$templateCache.put("/views/modals/last-modified-guard-modal.html",''),$templateCache.put("/views/modals/login-modal.html",''),$templateCache.put("/views/modals/pubtime-validation-modal.html",''),$templateCache.put("/views/modals/send-to-editor-modal.html",''),$templateCache.put("/views/modals/version-browser-modal.html",''),$templateCache.put("/views/nav.html",''),$templateCache.put("/views/promotion-tool-article-container.html",'
    No image selected.

    ·

    '),$templateCache.put("/views/promotion.html",'

    Currently promoted

    '),$templateCache.put("/views/pzones.html",'

    Promotion Zone Editor

    '),$templateCache.put("/views/pzones/carousel.html","
    Looks like this P'Zone is outdated
    "),$templateCache.put("/views/pzones/feature_type.html","
    Coming soon!
    "),$templateCache.put("/views/pzones/list.html",'
    Content IDActions
    '),$templateCache.put("/views/pzones/oneup.html","
    Looks like this P'Zone is outdated
    "),$templateCache.put("/views/pzones/reviews.html",'

    The "reviews" promoted zone has no available options.

    '),$templateCache.put("/views/pzones/twoup.html","
    Looks like this P'Zone is outdated
    "),$templateCache.put("/views/rating.html",'
    '),$templateCache.put("/views/save-button.html",""),$templateCache.put("/views/targeting-editor.html",'

    Targeting Editor

    '),$templateCache.put("/views/targeting.html",'
    KeyValue
    '),$templateCache.put("/views/titleimage.html",'
    '),$templateCache.put("/views/toolbar.html",'') }]); \ No newline at end of file diff --git a/dist/styles/main.css b/dist/styles/main.css index 3152c5b0c..349724868 100644 --- a/dist/styles/main.css +++ b/dist/styles/main.css @@ -1 +1 @@ -.cf:after,.cf:before{content:" ";display:table}.cf:after{clear:both}.cf{*zoom:1}button,input,textarea{outline:0}.image img{width:100%}body{background-color:#f1f1f1}#footer{text-align:center}#results .label{margin-left:4px}#results .label:first-child{margin-left:0}#refine legend{font-size:1em;line-height:1.786em;font-weight:700;text-transform:uppercase}#refine legend a{display:block}#refine .nav-header{padding-left:0}#refine.form-horizontal .control-group,#refine.form-horizontal legend{margin-bottom:10px}#logo,#logo img{width:50px;height:50px}.navbar-brand{padding:0;margin-left:15px}#button-area{position:fixed;right:25px;top:25px;display:block}#appbar{position:absolute;top:0;left:0;background-color:#333;width:100%;font-size:13px}#appbar a{padding:5px;color:#fff}#appbar a:hover{text-decoration:none}.pagination a{cursor:pointer}.autocomplete.dropdown{position:absolute;background-color:#fff;border:1px solid #CCC;border-top:0;z-index:1000}.autocomplete.dropdown .entry.selected{background-color:#4A88CE;color:#fff}.autocomplete.dropdown .entry{cursor:pointer}.autocomplete.dropdown .entry .glyphicon{margin-right:5px}#nprogress .bar{z-index:1000}.progress-overlay{display:none;position:absolute;width:100%;height:100%;top:0;left:0;z-index:999;background-color:rgba(50,50,50,.5)}.callout{border-left:5px solid #eee;margin:10px 0 0;padding:10px 30px 15px 15px}.callout p:last-child{margin-bottom:0}.callout:first-child{margin-top:0}.callout .highlight,.callout code{background-color:#fff}.callout h4{margin-top:0}.edit-page .editor a{background-color:red!important}.edit-page .editor a[href^="/"],.edit-page .editor a[href^=http],.edit-page .editor a[href^=mailto]{background-color:transparent!important}.hideOverflow{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}body{overflow-x:hidden}.panel-heading .published{display:inline-block;vertical-align:bottom;float:none;text-align:left}.publish-widget>a{cursor:pointer}td.preview{min-width:120px}td.feature-type abbr{max-width:100px;float:left}td.author{max-width:150px}.no-image{color:#EEE;display:block;font-size:100px;text-align:center;width:100%;transition:all .2s ease-in-out 0s}.no-image:hover{color:#dedede}.no-image .fa+span{clear:both;display:block;font-size:12px;font-weight:700;margin-bottom:20px;margin-top:-20px}.filter-object-container{margin-top:5px}.filter-object-container .clear-button:first-child{display:none}.filter-object-container .label{padding:.3em .6em;margin-right:3px;cursor:pointer}.filter-object-container .label span{margin-right:3px}.filterwidget .filter-input:focus{outline:0}.filterwidget .dropdown-menu{top:43px}.filterwidget .dropdown-menu li a{cursor:pointer}.filterwidget .dropdown-menu .glyphicon{margin-left:-7px;margin-right:7px}.panel .panel-heading{overflow:hidden;text-overflow:ellipsis;cursor:pointer;padding:6px 10px 7px}.panel .panel-heading .small{line-height:16px}.panel .panel-heading .panel-title{font-size:inherit;white-space:nowrap}#contentListAccordion .thumbnail{text-decoration:none!important}#contentListAccordion .panel-heading{padding:4px 5px}#contentListAccordion .panel-heading+.panel-collapse{margin-top:5px}#contentListAccordion .panel-heading+.panel-collapse .panel-body>div{padding-right:0;padding-left:0}#contentListAccordion .panel-heading+.panel-collapse .panel-body dt{margin-top:10px}#contentListAccordion .panel-heading+.panel-collapse .panel-body dt:first-child{margin-top:0}#create .enter-title-back{margin-left:-25px}#create .modal-body{padding-bottom:0}#create .modal-body button.go{width:100%;margin-top:5px}nav.navbar ul li:not(:first-child){border-left:1px solid #F1F1F1}.filterwidget{position:relative}#page-prev{margin-bottom:10px}#page-prev .h5{cursor:pointer;margin-bottom:0}#page-prev .h5+div{margin-top:10px}#page-prev .h5 .fa{padding:4px 2px}#page-prev .tab-pane{position:relative;margin:0 auto}#page-prev .tab-pane>div .inner{margin:0 auto;background:#fff;max-width:300px;width:auto;padding:10px}#page-prev .tab-pane>div img{border:1px solid #fff}#page-prev .nav{margin-right:10px}#page-prev .nav a{position:relative}#page-prev .tab-content{overflow:hidden}#page-prev #device-sm .article-01,#page-prev #device-sm .article-02{width:100%}#page-prev #device-sm .article-03,#page-prev #device-sm .article-04,#page-prev #device-sm .article-05,#page-prev #device-sm .article-06{width:40%;clear:both;margin-top:10px}#page-prev #device-md .article-01,#page-prev #device-md .article-02{width:100%}#page-prev #device-md .article-03,#page-prev #device-md .article-04,#page-prev #device-md .article-05,#page-prev #device-md .article-06{width:50%}#page-prev #device-lg .inner{max-width:600px}#page-prev #device-lg .article-01,#page-prev #device-lg .article-02{width:50%}#page-prev #device-lg .article-03,#page-prev #device-lg .article-04,#page-prev #device-lg .article-05,#page-prev #device-lg .article-06{width:25%}#pzone-content .close{margin-top:5px}#pzone-content .panel-heading,#targeting .panel-heading{cursor:default}.image-cropper-modal .modal-body .breather{padding-top:20px}.image-cropper-modal .modal-body .more-breathing{padding-bottom:20px}.image-cropper-modal .modal-body .thumb-list li{display:inline-block;height:180px;width:180px;margin:0 3px;position:relative}.image-cropper-modal .modal-body .thumb-list li.preview_thumb{height:110px;width:110px}.image-cropper-modal .modal-body .thumb-list li.preview_thumb .crop-overlay{display:block;background:rgba(0,0,0,.6)}.image-cropper-modal .modal-body .thumb-list li.preview_thumb .crop-overlay .overlay-text{font-size:20px;display:block}.image-cropper-modal .modal-body .thumb-list li:hover .crop-overlay{background:rgba(0,0,0,.6)}.image-cropper-modal .modal-body .thumb-list li:hover .crop-overlay .overlay-text{display:block}.image-cropper-modal .modal-body .thumb-list li .crop-overlay{position:absolute;z-index:2;top:0;left:0;right:0;bottom:0}.image-cropper-modal .modal-body .thumb-list li .crop-overlay .overlay-text{display:none;color:#fff;position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;text-align:center;height:64px;font-size:40px}.image-cropper-modal .modal-body .thumb-list li .cropped-thumb{overflow:hidden;position:absolute;top:0;left:0;right:0;bottom:0;margin:0 auto}.image-cropper-modal .modal-body .actions{text-align:center}.image-cropper-modal .modal-body .actions button{width:100%;margin-bottom:5px}.image-cropper-modal .modal-body .ratio-paginator span.fa-circle{margin:0 8px;color:#dedede}.edit-page bettyeditable .image-edit-container{padding:10px}.edit-page bettyeditable .image-edit-container .edit,.edit-page bettyeditable .image-edit-container .remove{bottom:auto;top:10px}.edit-page bettyeditable .image-edit-container .caption-alt{position:absolute;bottom:0;left:10px;width:101%}.btn-danger-copy{color:#fff;background-color:#d9534f;border-color:#d43f3a};.promotion-container .promotion-area{margin-bottom:20px}.promotion-container .panel-body{margin-bottom:0}.promotion-container .article{position:relative}.promotion-container .media{margin-top:10px;border-bottom:1px solid #ccc;padding-bottom:10px;padding-right:40px}.promotion-container .move-down,.promotion-container .move-up{margin:0;position:absolute;right:10px;z-index:10}.promotion-container .move-up{top:5px}.promotion-container .move-down{bottom:10px}.promotion-container .sidebar-articles-container{position:relative}.promotion-container .sidebar-article-container{border:1px solid #CCC;border-radius:4px;overflow:auto;position:relative}.promotion-container .sidebar-article-container .button-container{height:100%;position:absolute;width:60px}.promotion-container .sidebar-article-container .button-container button{height:50%;width:65px}.promotion-container .promotion-area.select-mode .article-container{border:1px solid #CCC;box-shadow:0 0 70px #CCC;cursor:pointer}.promotion-container .promotion-area.select-mode .article-container:hover{border:1px solid #428BCA;box-shadow:0 0 70px #428BCA}.promotion-container .promotion-container .filterwidget{padding:0;width:100%}.promotion-container .promotion-container .sidebar-articles-container{width:100%}.promotion-container .save-button-container{opacity:.8;position:fixed;right:50px;top:10px;width:100px;z-index:1000};#targeting .panel-heading{cursor:default}#targeting .targeting-group{margin-bottom:0}#targeting .targeting-group th{padding-top:0}#targeting .targeting-group td,#targeting .targeting-group th{border-top:0!important}#targeting .targeting-table{padding-top:0};.version-browser-container{height:500px}.version-browser-container ul{float:left;font-size:12px;width:200px;list-style-type:none;height:100%;overflow-y:scroll}.version-browser-container div{height:100%;overflow-y:scroll};.last-modified-preview .body-preview{max-height:400px;overflow-y:scroll;border:1px solid #CCC;border-radius:4px;padding:10px} \ No newline at end of file +.cf:after,.cf:before{content:" ";display:table}.cf:after{clear:both}.cf{*zoom:1}button,input,textarea{outline:0}.image img{width:100%}body{background-color:#f1f1f1}#footer{text-align:center}#results .label{margin-left:4px}#results .label:first-child{margin-left:0}#refine legend{font-size:1em;line-height:1.786em;font-weight:700;text-transform:uppercase}#refine legend a{display:block}#refine .nav-header{padding-left:0}#refine.form-horizontal .control-group,#refine.form-horizontal legend{margin-bottom:10px}#logo,#logo img{width:50px;height:50px}.navbar-brand{padding:0;margin-left:15px}#button-area{position:fixed;right:25px;top:25px;display:block}#appbar{position:absolute;top:0;left:0;background-color:#333;width:100%;font-size:13px}#appbar a{padding:5px;color:#fff}#appbar a:hover{text-decoration:none}.pagination a{cursor:pointer}.autocomplete.dropdown{position:absolute;background-color:#fff;border:1px solid #CCC;border-top:0;z-index:1000}.autocomplete.dropdown .entry.selected{background-color:#4A88CE;color:#fff}.autocomplete.dropdown .entry{cursor:pointer}.autocomplete.dropdown .entry .glyphicon{margin-right:5px}#nprogress .bar{z-index:1000}.progress-overlay{display:none;position:absolute;width:100%;height:100%;top:0;left:0;z-index:999;background-color:rgba(50,50,50,.5)}.callout{border-left:5px solid #eee;margin:10px 0 0;padding:10px 30px 15px 15px}.callout p:last-child{margin-bottom:0}.callout:first-child{margin-top:0}.callout .highlight,.callout code{background-color:#fff}.callout h4{margin-top:0}.edit-page .editor a{background-color:red!important}.edit-page .editor a[href^="/"],.edit-page .editor a[href^=http],.edit-page .editor a[href^=mailto]{background-color:transparent!important}.hideOverflow{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}body{overflow-x:hidden}.panel-heading .published{display:inline-block;vertical-align:bottom;float:none;text-align:left}.publish-widget>a{cursor:pointer}td.preview{min-width:120px}td.feature-type abbr{max-width:100px;float:left}td.author{max-width:150px}.no-image{color:#EEE;display:block;font-size:100px;text-align:center;width:100%;transition:all .2s ease-in-out 0s}.no-image:hover{color:#dedede}.no-image .fa+span{clear:both;display:block;font-size:12px;font-weight:700;margin-bottom:20px;margin-top:-20px}.filter-object-container{margin-top:5px}.filter-object-container .clear-button:first-child{display:none}.filter-object-container .label{padding:.3em .6em;margin-right:3px;cursor:pointer}.filter-object-container .label span{margin-right:3px}.filterwidget .filter-input:focus{outline:0}.filterwidget .dropdown-menu{top:43px}.filterwidget .dropdown-menu li a{cursor:pointer}.filterwidget .dropdown-menu .glyphicon{margin-left:-7px;margin-right:7px}.panel .panel-heading{overflow:hidden;text-overflow:ellipsis;cursor:pointer;padding:6px 10px 7px}.panel .panel-heading .small{line-height:16px}.panel .panel-heading .panel-title{font-size:inherit;white-space:nowrap}#contentListAccordion .thumbnail{text-decoration:none!important}#contentListAccordion .panel-heading{padding:4px 5px}#contentListAccordion .panel-heading+.panel-collapse{margin-top:5px}#contentListAccordion .panel-heading+.panel-collapse .panel-body>div{padding-right:0;padding-left:0}#contentListAccordion .panel-heading+.panel-collapse .panel-body dt{margin-top:10px}#contentListAccordion .panel-heading+.panel-collapse .panel-body dt:first-child{margin-top:0}#create .enter-title-back{margin-left:-25px}#create .modal-body{padding-bottom:0}#create .modal-body button.go{width:100%;margin-top:5px}nav.navbar ul li:not(:first-child){border-left:1px solid #F1F1F1}.filterwidget{position:relative}#page-prev{margin-bottom:10px}#page-prev .h5{cursor:pointer;margin-bottom:0}#page-prev .h5+div{margin-top:10px}#page-prev .h5 .fa{padding:4px 2px}#page-prev .tab-pane{position:relative;margin:0 auto}#page-prev .tab-pane>div .inner{margin:0 auto;background:#fff;max-width:300px;width:auto;padding:10px}#page-prev .tab-pane>div img{border:1px solid #fff}#page-prev .nav{margin-right:10px}#page-prev .nav a{position:relative}#page-prev .tab-content{overflow:hidden}#page-prev #device-sm .article-01,#page-prev #device-sm .article-02{width:100%}#page-prev #device-sm .article-03,#page-prev #device-sm .article-04,#page-prev #device-sm .article-05,#page-prev #device-sm .article-06{width:40%;clear:both;margin-top:10px}#page-prev #device-md .article-01,#page-prev #device-md .article-02{width:100%}#page-prev #device-md .article-03,#page-prev #device-md .article-04,#page-prev #device-md .article-05,#page-prev #device-md .article-06{width:50%}#page-prev #device-lg .inner{max-width:600px}#page-prev #device-lg .article-01,#page-prev #device-lg .article-02{width:50%}#page-prev #device-lg .article-03,#page-prev #device-lg .article-04,#page-prev #device-lg .article-05,#page-prev #device-lg .article-06{width:25%}#pzone-content .close{margin-top:5px}#pzone-content .panel-heading,#targeting .panel-heading{cursor:default}.image-cropper-modal .modal-body .breather{padding-top:20px}.image-cropper-modal .modal-body .more-breathing{padding-bottom:20px}.image-cropper-modal .modal-body .thumb-list li{display:inline-block;height:180px;width:180px;margin:0 3px;position:relative}.image-cropper-modal .modal-body .thumb-list li.preview_thumb{height:110px;width:110px}.image-cropper-modal .modal-body .thumb-list li.preview_thumb .crop-overlay{display:block;background:rgba(0,0,0,.6)}.image-cropper-modal .modal-body .thumb-list li.preview_thumb .crop-overlay .overlay-text{font-size:20px;display:block}.image-cropper-modal .modal-body .thumb-list li:hover .crop-overlay{background:rgba(0,0,0,.6)}.image-cropper-modal .modal-body .thumb-list li:hover .crop-overlay .overlay-text{display:block}.image-cropper-modal .modal-body .thumb-list li .crop-overlay{position:absolute;z-index:2;top:0;left:0;right:0;bottom:0}.image-cropper-modal .modal-body .thumb-list li .crop-overlay .overlay-text{display:none;color:#fff;position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;text-align:center;height:64px;font-size:40px}.image-cropper-modal .modal-body .thumb-list li .cropped-thumb{overflow:hidden;position:absolute;top:0;left:0;right:0;bottom:0;margin:0 auto}.image-cropper-modal .modal-body .actions{text-align:center}.image-cropper-modal .modal-body .actions button{width:100%;margin-bottom:5px}.image-cropper-modal .modal-body .ratio-paginator span.fa-circle{margin:0 8px;color:#dedede}.edit-page bettyeditable .image-edit-container{padding:10px}.edit-page bettyeditable .image-edit-container .edit,.edit-page bettyeditable .image-edit-container .remove{bottom:auto;top:10px}.edit-page bettyeditable .image-edit-container .caption-alt{position:absolute;bottom:0;left:10px;width:101%}.btn-danger-copy{color:#fff;background-color:#d9534f;border-color:#d43f3a};.promotion-container .promotion-area{margin-bottom:20px}.promotion-container .panel-body{margin-bottom:0}.promotion-container .article{position:relative}.promotion-container .media{margin-top:10px;border-bottom:1px solid #ccc;padding-bottom:10px;padding-right:40px}.promotion-container .move-down,.promotion-container .move-up{margin:0;position:absolute;right:10px;z-index:10}.promotion-container .move-up{top:5px}.promotion-container .move-down{bottom:10px}.promotion-container .sidebar-articles-container{position:relative}.promotion-container .sidebar-article-container{border:1px solid #CCC;border-radius:4px;overflow:auto;position:relative}.promotion-container .sidebar-article-container .button-container{height:100%;position:absolute;width:60px}.promotion-container .sidebar-article-container .button-container button{height:50%;width:65px}.promotion-container .promotion-area.select-mode .article-container{border:1px solid #CCC;box-shadow:0 0 70px #CCC;cursor:pointer}.promotion-container .promotion-area.select-mode .article-container:hover{border:1px solid #428BCA;box-shadow:0 0 70px #428BCA}.promotion-container .promotion-container .filterwidget{padding:0;width:100%}.promotion-container .promotion-container .sidebar-articles-container{width:100%}.promotion-container .save-button-container{opacity:.8;position:fixed;right:50px;top:10px;width:100px;z-index:1000};#targeting .panel-heading{cursor:default}#targeting .targeting-group{margin-bottom:0}#targeting .targeting-group th{padding-top:0}#targeting .targeting-group td,#targeting .targeting-group th{border-top:0!important}#targeting .targeting-table{padding-top:0};.version-browser-container{height:500px}.version-browser-container ul{float:left;font-size:12px;width:200px;list-style-type:none;height:100%;overflow-y:scroll}.version-browser-container div{height:100%;overflow-y:scroll};.last-modified-preview .body-preview{max-height:400px;overflow-y:scroll} \ No newline at end of file